import React, { createContext, ReactNode, useContext, useState } from 'react'; import CacheStore from './modules/cache'; const CacheContext = createContext(null); interface Props { children: ReactNode; name?: string; } export default function CacheProvider({ children, name }: Props) { const [store] = useState(() => new CacheStore({ name, persistent: true })); return {children}; } export function useCacheStore(): CacheStore | null { return useContext(CacheContext); }