diff --git a/tests/03_component.spec.tsx b/tests/03_component.spec.tsx index f6c9e14..04be4ff 100644 --- a/tests/03_component.spec.tsx +++ b/tests/03_component.spec.tsx @@ -16,10 +16,15 @@ type ExtractState = S extends { function createZustandContext>( initializeStore: () => Store, ) { - const Context = createContext(null); + const Context = createContext(undefined); const StoreProvider = ({ children }: { children: ReactNode }) => { - const store = useRef(initializeStore()).current; - return {children}; + const storeRef = useRef(); + if (!storeRef.current) { + storeRef.current = initializeStore(); + } + return ( + {children} + ); }; function useStoreApi() { const store = useContext(Context);