Skip to main content

makeCacheProvider()

declare const makeCacheProvider: (
managers: Manager[],
initialState?: State<unknown>,
) => ({ children }: { children: React.ReactNode }) => JSX.Element;
Deprecated

In @rest-hooks/test>=10, <CacheProvider /> should be used directly

For previous versions, this is used to build a <CacheProvider /> for makeRenderRestHook()

Arguments

managers

Manager

initialState

Can be used to prime the cache if test expects cache values to already be filled.

Returns

Simple wrapper component that only has child as prop.

import makeCacheProvider from '@rest-hooks/react/makeCacheProvider';

const manager = new MockNetworkManager();
const subscriptionManager = new SubscriptionManager(PollingSubscription);
const Provider = makeCacheProvider([manager, subscriptionManager]);

function renderRestHook<T>(callback: () => T) {
return renderHook(callback, {
wrapper: ({ children }) => <Provider>{children}</Provider>,
});
}