DEV Community

Discussion on: No Fuss Dark-Mode Toggle with React & Styled-Components! πŸŒžβ†”οΈπŸŒ–

Collapse
 
adelekand profile image
David Adelekan • Edited

Isn't it a better approach to have a theme provider at the top level component that would take the theme object as a prop based on the value of isDarkMode, instead of having to do the comparison for each of the components. This is not sustainable for a large project that have many components.

Edit:
I wrote this comment not knowing the suggestion has already been made

Collapse
 
hyggedev profile image
Chris Hansen

Well in my honest opinion you are πŸ’― percent right! My aim was to basically introduce styled components, and to have the least resistance for entry for beginners. Info have a goal of updating this into a series and introducing React context, dark mode hooks, or themeprovider. Thanks for dropping by!