Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const ThemeContext = React.createContext('light');
  2.  
  3. const Display = () => {
  4. const theme = useContext(ThemeContext);
  5. return <div
  6. style={{
  7. background: theme === 'dark' ? 'black' : 'papayawhip',
  8. color: theme === 'dark' ? 'white' : 'palevioletred',
  9. width: '100%',
  10. minHeight: '200px'
  11. }}
  12. >
  13. {'The theme here is ' + theme}
  14. </div>
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement