Light Dark Mode React - Without Any Libraries

preview_player
Показать описание
Learn how to toggle between dark and light mode in React using React context. We will implement from scratch support of different themes and subscribing to this data in component of any level using useContext hook. If you want to learn how to toggle between dark and light mode in React then this video is for you.

FOLLOW ME

REFERENCES

RECOMMENDED VIDEOS

STUFF I USE

Disclosures: All opinions are my own. Sponsors are acknowledged. Some links in the description are affiliate links that if you click on one of the product links, I’ll receive a commission at no additional cost to you. As an Amazon Associate I earn a small commission from qualifying purchases.
Рекомендации по теме
Комментарии
Автор

how could you show us this much content in 14 minutes.
this was incredible!

walassi
Автор

would have taken me a whole lot of time doing it by myself :( so thanks for your help !!keep up the good work:)

prateek
Автор

Really nice and clear code, Thank you for sharing this :)

EleceG
Автор

Interesting tuturiol, Awesome...
Subscribed

computerscience
Автор

Thanks for the video. Really helped me with my react project.

sd-kgtq
Автор

Great usage of context. It is a nice video to start with and expand further according to your needs.
By the way, it is better to use "useLayoutEffect hook" instead of "useEffect hook". Because your current implementation causes CSS flickering while the page is being reloaded.

alexanderborisov
Автор

The video was amazing man!🎉 Thank a lot. Could you make a video to show how to create multi language app using React Context, please?

samarosman
Автор

I didn't know react could do this!

katarinatiaotiao
Автор

Interesting approach, but 1 question, isnt it easier to have in index css on body a set of color variables and just rewrite them with darktheme class and its color values. darktheme class is added on the body via some kind of a toggler

unknownrus
Автор

I understood the video, but what if i don't want to use style attribute for my tags, instead I want it to use in custom styled component file. How we can do that ? Please, I'm stuck on this, and I really want to get this done. Any suggestions or help ?

dhavaljprasad
Автор

how we can add multiple style on one theme mode? I am trying but it is not working at all, Please help :(

denver
Автор

This is more complicated than vanilla javascript XD

workmoneyworkmoney
Автор

How do you do this for more than 2 themes

jixster
Автор

This tutorial is very basic. It can be applied on 1% of basic sites. Try toggle an app between 2 bootstrap themes light and dark, and you will see what i am saying. There will be the flicker on switch. And other problems. You will need a script tag before react initialize to block react and get the browser selected theme and from there the things get complicated if you have autentification... get user preferences from db .. light, dark, or no selection ... from there to put in localstorage.. and so on. This tutorial is 1% of what must be done.

eduardstransky