Last active
July 23, 2019 20:07
-
-
Save jrwebdev/68e50bcd9ef2a125933355369c155047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Theme = 'light' | 'dark'; | |
const ThemeContext = createContext<Theme>('dark'); | |
const App = () => ( | |
<ThemeContext.Provider value="dark"> | |
<MyComponent /> | |
</ThemeContext.Provider> | |
) | |
const MyComponent = () => { | |
const theme = useContext(ThemeContext); | |
return <div>The theme is {theme}</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment