UNPKG

seti-ramesesv1

Version:

Reusable components and context for Next.js apps

22 lines (19 loc) 752 B
import { jsx } from 'react/jsx-runtime'; import { createContext, useState, useContext } from 'react'; const ContentContext = createContext(undefined); const ContentProvider = ({ children }) => { const [content, setContentState] = useState({}); const setContent = (id, component) => { setContentState((prev) => ({ ...prev, [id]: component })); }; return jsx(ContentContext.Provider, { value: { content, setContent }, children: children }); }; const useContent = () => { const context = useContext(ContentContext); if (!context) { throw new Error("useContent must be used within a ContentProvider"); } return context; }; export { ContentProvider, useContent }; //# sourceMappingURL=ContentContext.js.map