Skip to content

Instantly share code, notes, and snippets.

@imaginamundo
Created May 5, 2021 20:08
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 imaginamundo/96cb2a2bf08967cef636b0a0c5f4b68a to your computer and use it in GitHub Desktop.
Save imaginamundo/96cb2a2bf08967cef636b0a0c5f4b68a to your computer and use it in GitHub Desktop.
import React, { createContext, useContext, useState } from "react";
const Context = createContext({});
export function AuthContextProvider({ children }) {
const [ auth, setAuth ] = useState(null);
return (
<Context.Provider value={ { auth, setAuth } }>
{ children }
</Context.Provider>
);
}
export default function useAuthContext() {
return useContext(Context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment