DEV Community

Discussion on: No Fuss Dark-Mode Toggle with React & Styled-Components! ๐ŸŒžโ†”๏ธ๐ŸŒ–

Collapse
 
goodok21 profile image
Alexander Eric

Sorry, but itโ€™s bad approach, just to pass props to each component about selected modeโ€ฆ at least you have to use styled theme context or css variables or whatever, but not like this

Collapse
 
hyggedev profile image
Chris Hansen

This is definitely not the end goal. For beginners who are testing the waters, this is the easiest way imo to get something up and running asap. Context and Local storage would make this much better. But as for styled-components, this totally works!

Collapse
 
goodok21 profile image
Alexander Eric

You want to provide context about dark mode? And get this context state in components and then pass as props again to styled components? ;) just use styled-components theme, and to persist state you can use local storage for sure ๐Ÿ˜‰

Beginners need to learn good patterns - this is the most important thing, imho ๐Ÿ™‚

Thread Thread
 
hyggedev profile image
Chris Hansen

Update coming soon ๐Ÿ˜‰