Skip to content

Instantly share code, notes, and snippets.

@jamiehaywood
Created November 22, 2020 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiehaywood/3ffc382a35f632891f8190f7ee6e1ab6 to your computer and use it in GitHub Desktop.
Save jamiehaywood/3ffc382a35f632891f8190f7ee6e1ab6 to your computer and use it in GitHub Desktop.
const GlobalStateProvider = ({
children,
value = {} as GlobalStateInterface,
}: {
children: React.ReactNode;
value?: Partial<GlobalStateInterface>;
}) => {
const [state, setState] = useState(value);
return (
<GlobalStateContext.Provider value={{ state, setState }}>
{children}
</GlobalStateContext.Provider>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment