react-forecast-query
Version:
Higher order React component delivering weather information from open weather api. Wrapper for forecast-query package.
49 lines (48 loc) • 1.92 kB
TypeScript
import { ForecastList, Forecast } from 'forecast-query/types';
import React from 'react';
declare type ForecastResults = {
[K in keyof ForecastList]?: ForecastList[K] extends () => Promise<infer U> ? U : never;
};
export interface InjectedForecastResults {
data: ForecastResults;
forecast: Forecast;
}
export interface InjectedForecastPropsCommon {
/**
* openweathermap api key
*/
apiKey: string;
/**
* What kind of weather information do you want to see?
*/
query: Array<keyof ForecastList>;
/**
* Do you own a pro account?
*/
isPro?: boolean;
/**
* Should the query be listed by hour or by day
*/
by?: 'day' | 'hour';
/**
* Set up your forecast location and dates
*/
setup?: (forecast: Forecast) => void;
loadingComponent?: () => JSX.Element | null;
errorComponent?: (props: {
error: any;
}) => JSX.Element | null;
}
interface InjectedForecastPropsGeo {
geo: true;
/**
* Update periodically in minutes. This will be set up componentDidMount
*/
updateGeo?: number;
}
interface InjectedForecastPropsNoGeo {
geo?: false;
}
export declare type InjectedForecastProps = InjectedForecastPropsCommon & (InjectedForecastPropsGeo | InjectedForecastPropsNoGeo);
declare const weatherEnhancer: <T extends object>(Component: (new (props: T & ForecastResults) => React.Component<T & ForecastResults, {}, any>) | ((props: T & ForecastResults) => JSX.Element | null), storage?: Storage, expire?: number | "never" | undefined) => (props: (Pick<Pick<T, Exclude<keyof T, "data">>, Exclude<Exclude<keyof T, "data">, "forecast">> & InjectedForecastPropsCommon & InjectedForecastPropsGeo) | (Pick<Pick<T, Exclude<keyof T, "data">>, Exclude<Exclude<keyof T, "data">, "forecast">> & InjectedForecastPropsCommon & InjectedForecastPropsNoGeo)) => JSX.Element;
export default weatherEnhancer;