Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ThemeContext = React.createContext('light');
- const Display = () => {
- const theme = useContext(ThemeContext);
- return <div
- style={{
- background: theme === 'dark' ? 'black' : 'papayawhip',
- color: theme === 'dark' ? 'white' : 'palevioletred',
- width: '100%',
- minHeight: '200px'
- }}
- >
- {'The theme here is ' + theme}
- </div>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement