Skip to content

Instantly share code, notes, and snippets.

@Gerhut
Created July 1, 2019 12:04
Show Gist options
  • Save Gerhut/20447465d9a693559c688b55ac84618c to your computer and use it in GitHub Desktop.
Save Gerhut/20447465d9a693559c688b55ac84618c to your computer and use it in GitHub Desktop.
import React, {
createContext,
useState,
useContext
} from 'react'
const AppContext = createContext({
checking: true,
setChecking (checking) {}
})
export function AppProvider ({ children }) {
const [checking, setChecking] = useState(true)
const value = { checking, setChecking }
return (
<AppContext.Provider
value={value}
children={children}
/>
)
}
export default function useApp () {
return useContext(AppContext)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment