Skip to main content
Version: 6.4

<ExternalCacheProvider />

Integrates external stores with rest-hooks. Should be placed as high as possible in application tree as any usage of the hooks is only possible for components below the provider in the React tree.

Is a replacement for <CacheProvider /> - do NOT use both at once

import { ExternalCacheProvider } from 'rest-hooks';
import ReactDOM from 'react-dom';

import { store, selector } from './store';

<ExternalCacheProvider store={store} selector={selector}>
<App />

See redux example for a more complete example.


interface Store<S> {
subscribe(listener: () => void): () => void;
dispatch: React.Dispatch<ActionTypes>;
getState(): S;

Store simply needs to conform to this interface. A common implementation is a redux store, but theoretically any external store could be used.

Read more about integrating redux.


(state: S) => State<unknown>

This function is used to retrieve the rest-hooks specific part of the store's state tree.