Light Dark Mode React - Without Any Libraries

  Рет қаралды 8,124

Monsterlessons Academy

Monsterlessons Academy

Күн бұрын

Пікірлер: 38
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
WATCH NEXT: React Interview Questions and Answers - Dominate Your Next Interview - kzbin.info/www/bejne/r4Kro2elpd-ShJIsi=51b2XP_84GH3q6oF
@prateek4279
@prateek4279 9 ай бұрын
would have taken me a whole lot of time doing it by myself :( so thanks for your help !!keep up the good work:)
@MonsterlessonsAcademy
@MonsterlessonsAcademy 9 ай бұрын
Glad I could help!
@walassi834
@walassi834 Жыл бұрын
how could you show us this much content in 14 minutes. this was incredible!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Magic!
@EleceG
@EleceG 7 ай бұрын
Really nice and clear code, Thank you for sharing this :)
@MonsterlessonsAcademy
@MonsterlessonsAcademy 7 ай бұрын
You're welcome!
@computerscience1152
@computerscience1152 3 жыл бұрын
Interesting tuturiol, Awesome... Subscribed
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
Thanks for the sub!
@unknownrus920
@unknownrus920 3 жыл бұрын
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
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
The main problem with your approach is that css and color variable are not usable inside js. Which means we can't write logic, conditions, etc with them. Here are can do that because it's in js.Theme is not only colors, it can be margins, paddings, sizes, booleans, etc. P.S. But if you just have several global variables your approach may be easier.
@dhavaljprasad
@dhavaljprasad 11 ай бұрын
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 ?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 11 ай бұрын
You can store just theme name and render different components depending on the them. Or provide different props to styled comp.
@samarosman7110
@samarosman7110 10 ай бұрын
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?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 10 ай бұрын
I will add your idea in the list of future videos
@sd-kg8tq
@sd-kg8tq 2 жыл бұрын
Thanks for the video. Really helped me with my react project.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Great to hear!
@alexanderborisov1828
@alexanderborisov1828 2 жыл бұрын
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.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Yes, you are totally right!
@sd-kg8tq
@sd-kg8tq 2 жыл бұрын
Thanks for that. Saved me time to start looking for a solution. Works great.
@tanushridas8264
@tanushridas8264 Жыл бұрын
Thanks brother
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@YaroslavEx
@YaroslavEx Жыл бұрын
дякую!
@denver3583
@denver3583 Жыл бұрын
how we can add multiple style on one theme mode? I am trying but it is not working at all, Please help :(
@mehdijafarzade2381
@mehdijafarzade2381 5 ай бұрын
awesome bro
@MonsterlessonsAcademy
@MonsterlessonsAcademy 5 ай бұрын
thanks
@pro-cr2eo
@pro-cr2eo 3 жыл бұрын
amazing! Thanks for the video.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
Glad you liked it!
@jixster1566
@jixster1566 Жыл бұрын
How do you do this for more than 2 themes
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Store not boolean but a string with theme name.
@katarina4tiaotiao
@katarina4tiaotiao 3 жыл бұрын
I didn't know react could do this!
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
Something new every day :)
@gigakvachakhia4777
@gigakvachakhia4777 3 жыл бұрын
interesting video as always.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 3 жыл бұрын
Glad you enjoyed it
@workmoneyworkmoney
@workmoneyworkmoney Жыл бұрын
This is more complicated than vanilla javascript XD
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Sure but it is difficult to build big production apps with vanilla
@eduardstransky7722
@eduardstransky7722 2 жыл бұрын
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.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Well, yes. it was never intended to be a fully featured production solution with all possible cases :)
Build a dark mode light mode in reactjs with context api
29:20
Hitesh Choudhary
Рет қаралды 28 М.
React Project: Creating a dark mode toggle using the Context API
23:52
Code With Bubb
Рет қаралды 4,3 М.
小丑在游泳池做什么#short #angel #clown
00:13
Super Beauty team
Рет қаралды 43 МЛН
iPhone or Chocolate??
00:16
Hungry FAM
Рет қаралды 29 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,4 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 67 МЛН
React Redux Toolkit Crash Course (createAsyncThunk, createSlice)
18:13
Monsterlessons Academy
Рет қаралды 9 М.
5 Must Know React Interview Questions (They Ask Them Always)
7:07
Monsterlessons Academy
Рет қаралды 13 М.
React Dark Theme Toggle With Styled Components Tutorial
11:56
Nikita Dev
Рет қаралды 14 М.
React Suspense Loading - Lazy Loading in React
8:30
Monsterlessons Academy
Рет қаралды 8 М.
Usecallback React Hooks Example - Learn by Doing
13:12
Monsterlessons Academy
Рет қаралды 3,6 М.
Light / Dark Mode Toggle In React Tutorial
16:02
PedroTech
Рет қаралды 99 М.
You’re doing dark mode wrong!
7:54
Coding in Public
Рет қаралды 51 М.
Провайдер темы в React JS за 7 минут | React Theme Provider
7:40
Типичный Веб Разработчик
Рет қаралды 2,6 М.
React Context API - Toggling Dark Mode the right way
19:45
Lyrad Digital
Рет қаралды 6 М.
小丑在游泳池做什么#short #angel #clown
00:13
Super Beauty team
Рет қаралды 43 МЛН