UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

14 lines (13 loc) 567 B
import { type ReactElement, type ReactNode } from "react"; /** * Create a cache context that can be provided to React elements and allows them to call `useCache()` * - Cache is a `Map` indexed by strings that can be used to store any value. */ export declare function createCacheContext<T>(): { /** Wrap around a set of elements to provide the cache to them. */ readonly CacheContext: ({ children }: { children: ReactNode; }) => ReactElement; /** Use the current cache map in a component. */ readonly useCache: () => Map<string, T>; };