Advertisement
afzalsiddique

FunctionContextComponent.js

Sep 18th, 2021
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {useTheme,useThemeUpdate} from "../ThemeContext";
  2.  
  3. export default function FunctionContextComponent(){
  4.   const darkTheme = useTheme()
  5.   const toggleTheme = useThemeUpdate()
  6.   const themeStyles = {
  7.     backgroundColor:darkTheme?'#333':'#CCC'
  8.   }
  9.   return (
  10.     <>
  11.       <button onClick={toggleTheme}>toggle Theme</button>
  12.       <div style={themeStyles}>Function Theme</div>
  13.     </>
  14.   )
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement