"use client"; import { createContext, useRef } from "react"; import { createAlertStore, createAttachmentStore, createMenuStore, createUserStore, } from "../store"; type StoreContextType = { alertStore: ReturnType; attachmentStore: ReturnType; menuStore: ReturnType; userStore: ReturnType; }; export const StoreContext = createContext( undefined, ); export const StoreProvider = ({ children }: { children: React.ReactNode }) => { const storeRef = useRef(null); if (storeRef.current === null) { storeRef.current = { alertStore: createAlertStore(), attachmentStore: createAttachmentStore(), menuStore: createMenuStore(), userStore: createUserStore(), }; } return ( {children} ); };