Skip to main content
Version: 4.5

makeCacheProvider()

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

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.

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>,
});
}