UNPKG

react-simple-api

Version:

Create and cache API requests and responses

14 lines (13 loc) 535 B
import React, { Context, ReactNode } from 'react'; interface ApiCacheContextData { getCache<T>(id: string): T; setCache<T>(id: string, data: T, cacheExpiry?: number): T; baseApiUrl?: string; } declare const ApiCacheContext: Context<ApiCacheContextData>; declare const ApiContextProvider: ({ children, baseApiUrl }: { children: ReactNode; baseApiUrl?: string | undefined; }) => React.JSX.Element; declare const useApiContext: () => ApiCacheContextData; export { ApiContextProvider, ApiCacheContext, useApiContext };