DEV Community

Discussion on: React Instant Theme Toggler using pure CSS

Collapse
 
narendersaini32 profile image
Narender Saini

Thanks for nice article. Can you explain why you used useEffect in the useTheme hook.

Collapse
 
ghackdev profile image
ghack.dev

useEffect is used to listen if the selectedTheme is changed. So the function passed to the useEffect hook will be called whenever the selectedTheme variable changed.

Collapse
 
narendersaini32 profile image
Narender Saini

Thanks