Learn React Hooks: useState - Simply Explained!

  Рет қаралды 66,415

Cosden Solutions

Cosden Solutions

Күн бұрын

Пікірлер: 101
@cosdensolutions
@cosdensolutions 8 ай бұрын
Hope you enjoyed the video! I also have a really cool and unique course that will teach you way more than this video. You'll learn how to build an actual complex project with React. It's called "Project React" and you can find it at cosden.solutions/project-react. Also, I have a free weekly newsletter called "Import React" with tutorials, news, and cool stuff about React! You can sign up at cosden.solutions/newsletter?s=ytc
@Infotainment-cb6cy
@Infotainment-cb6cy 2 ай бұрын
You explained nothinng const [count, setCount] = useState(0); still does not make any sense at all.
@bbbeo8912
@bbbeo8912 10 ай бұрын
Hi Cosden, I have been working with Angular for years and now I'm learning React to enrich my skillset as a front end developer. Your videos is always concise and easy to understand that help me to save a lot of time. Thank you so much.
@CMOMKARSHELKECM
@CMOMKARSHELKECM 4 ай бұрын
The way you teach react tells how experienced you are Keep uploading videos
@zuperhache
@zuperhache 8 ай бұрын
finally !! after watching 1000s of videos, a dude that explains! clearly how the hooks work, thank you ! 🙏💪
@huangjian7749
@huangjian7749 12 күн бұрын
hello、i am Chinese as a backend developer! however my english very bad!so i take you video as learning English video ❤😂
@percyk6884
@percyk6884 Жыл бұрын
Simple, quick, and efficient, thank you!
@spongebobsquarepants4576
@spongebobsquarepants4576 4 ай бұрын
bro, this is seriously the best explanation on youtube. Please keep them coming!
@Nelson-fw5ly
@Nelson-fw5ly Жыл бұрын
so because of useState(), I can click the 'Like' button on this video and the like counter can increment? 😆
@cosdensolutions
@cosdensolutions Жыл бұрын
Hahahaha yes exactly ☺️
@bbbeo8912
@bbbeo8912 10 ай бұрын
Then click on it again to test the decrement :)) Lol j4f don't do that haha
@Guyfromearh1
@Guyfromearh1 Ай бұрын
But the question is how users can only do it once.
@Electro_69
@Electro_69 6 ай бұрын
Daaaaamn you are a god or what, i wasted my 5 hours on this and you taught me in 10 minutes, salute man
@alowoesintoluwalase1154
@alowoesintoluwalase1154 21 күн бұрын
Thank you very much so simple to understand from you
@FursMars
@FursMars Жыл бұрын
You are the best teacher! Thank you for you real help and your tami and work!!!
@shortsofsomeone
@shortsofsomeone 6 ай бұрын
Really, this was my last tutorial for using the state hook. Thanks for your effort.💗
@janemisshela
@janemisshela 6 ай бұрын
You simplified the complexity of this concept! Thanks so much!
@SandroZabakhidze
@SandroZabakhidze 2 ай бұрын
best tutorial i have se in a while
@tea2125
@tea2125 8 ай бұрын
You are an amazing teacher! Thank you!
@sgtkang2
@sgtkang2 2 ай бұрын
Oh my.. you explain it so well!
@priyamjain01
@priyamjain01 6 ай бұрын
You are a saviour my friend 🙏
@mission-DIY
@mission-DIY 3 ай бұрын
I like the way you explain things that other videos do not explain, such is the naming conventions! Great work. Subscribed!
@deyonyt
@deyonyt 3 ай бұрын
really appreciate the small videos explaining big concepts so well but i think you should have talked about the asynchronous nature of useState here. in real world applications, more often than not ive gotten stumped by this async nature where the state just wont update! would really appreciate a video on that, if possible!
@cosdensolutions
@cosdensolutions 3 ай бұрын
fair enough, this was my first ever video though 😅
@rusliabdulgani9920
@rusliabdulgani9920 11 ай бұрын
the setState is tricky, cause if you do like that (setCount(count + 1) ) and when there is another async process that change the state, the value will not valid.. you should use this approach setCount(recentCount => recentCount + 1 ) it will using recent value and calculate it.
@rusliabdulgani9920
@rusliabdulgani9920 11 ай бұрын
so if there is any recent value involve, please make sure using this approach (using callback), rather than directly inject state
@jasonadams1876
@jasonadams1876 5 ай бұрын
Yes, this is correct. It's nice that this video present this as simply as possible, but doing things the way it's presenting is going to set devs up for future confusion and problems.
@Thekidisalright
@Thekidisalright 2 ай бұрын
I was actually surprise he just use (count + 1) instead of update the count with recentCount instead
@boukrimohammed
@boukrimohammed 9 ай бұрын
i swear you're a life saver
@narcleptik
@narcleptik 11 ай бұрын
Thank You, you are a good teacher.
@mustafacoskun5208
@mustafacoskun5208 11 ай бұрын
Thanks for clear and to the target explanation...
@richardclifford583
@richardclifford583 11 ай бұрын
Very simplified explanation! Thanks!
@sarahwbas
@sarahwbas 8 ай бұрын
Thank You so much! your channel is underrated!
@renejacques8288
@renejacques8288 9 ай бұрын
I guess you were right; I do have a better understanding of useStates now. What gets me is the word interface you used.
@alissoncamoes7113
@alissoncamoes7113 Жыл бұрын
thank you for sharing, greetings from Brazil!
@rinshadrinshad3540
@rinshadrinshad3540 Жыл бұрын
Simple and detail Thanks For The Effort 🙌
@TheHumanistX
@TheHumanistX Жыл бұрын
Enjoying your channel. Subscribed. I have seen a few times people mention (usually using this counter example) that was should do something like `setCount(prevState => prevstate + 1)` I can't remember the reasoning for this but it had something to do with the state properly updating? Do you know what I am talking about and could you disucss that? Is it needed? Why do we do this instead of just `setCount(count + 1)`?
@cosdensolutions
@cosdensolutions Жыл бұрын
Doing it that way is a way to guarantee you're getting the most up to date state, which sometimes is harder to get because of how React renders work. Search examples for this online and you'll see why
@kristiankristian4652
@kristiankristian4652 11 ай бұрын
ok, yes that's a simple example, but should to mention about "prev" because an App going to be crashed once when we change many useStates in the same time.
@technologic4575
@technologic4575 10 ай бұрын
Nice video but I was expecting that you could explain more about the difference between using function to set a state ex. instead of setCount(count + 1) others are using setCount(prevState => prevState + 1)
@rusliabdulgani9920
@rusliabdulgani9920 10 ай бұрын
cause setState function is async process, so the React do not guarantee that if you use this approach (setCount(count + 1)) it will always correct, so react give you saver approach (setCount(callback)) to make sure your function to set the state will be always correct.
@OXIDE777-is6gs
@OXIDE777-is6gs Жыл бұрын
Awesome!!! please do more of those on other React subjects🙏
@cosdensolutions
@cosdensolutions Жыл бұрын
Yep 🤙
@TEScompetitive
@TEScompetitive Жыл бұрын
Much appreciated, best tutorial out on this
@andrewchukwudumeje9413
@andrewchukwudumeje9413 7 ай бұрын
I love the explanation bro Thanks a lot Keep up the good work
@enochdollar-bill3306
@enochdollar-bill3306 3 ай бұрын
made it make too much sense, i think imma watch ur playlist now
@metcaelfe
@metcaelfe 4 ай бұрын
Subbed, your videos and explanations are fantastic! Thank you!
@GeraldPajulas
@GeraldPajulas 10 ай бұрын
Thank you for this. I understand the useState now hahaha😆😆
@lll-vq6pm
@lll-vq6pm 4 ай бұрын
Sir can you instead show us how to use useState in manipulating DOM elements or classes. That would be more helpful to us beginners who is more into designing our react apps as an aspiring frontend dev.. just suggesting thankyou for your videos ❤️
@Salah-YT
@Salah-YT Жыл бұрын
Lovely job, bro! Subscribed and liked. Please cover each hook individually and create a list, it would be awesome. Thanks a lot! 😍👍
@cosdensolutions
@cosdensolutions Жыл бұрын
There's a playlist already ☺️ but yes planning to do all of them
@Scotthutchinsonking
@Scotthutchinsonking 11 ай бұрын
this dude is awesome
@jabiesorenson8271
@jabiesorenson8271 9 ай бұрын
Just subbed cause I like the way you describe things good job
@RobixYTT-nu4ug
@RobixYTT-nu4ug 11 ай бұрын
Thanks for the video and for the taking the time to explain how useState works. It is so damn simple. Now, I am going to teach this to my mentees. They won't know that this is me as I am not using my real name,. hahaha! Thanks a lot!
@manushadananjaya8125
@manushadananjaya8125 Жыл бұрын
Greetings Good luck! From Sri lanka❤
@cosdensolutions
@cosdensolutions Жыл бұрын
thank you! love sri lanka :D colombo is a great city
@Adrianku
@Adrianku 11 ай бұрын
just WOW! this was really helpful! thanks! new sub here
@eunwoooscomics
@eunwoooscomics Жыл бұрын
I loved this video keep up the good work
@abzz1290
@abzz1290 11 ай бұрын
Great. How to handle multiple or object and array in useState?
@manushadananjaya8125
@manushadananjaya8125 Жыл бұрын
Thank you soo much this is so much better 😍
@cosdensolutions
@cosdensolutions Жыл бұрын
glad you found it useful!
@kadirmemisoglu343
@kadirmemisoglu343 Жыл бұрын
I like your video but you did not mention about preVal in state. I think this is so important that you can not avoid to mention
@mazthespaz1
@mazthespaz1 3 ай бұрын
but you didn't say how the rest of the program gets access to the count value. should the count functions broadcast messages when count has changed?
@madipallynaveenkumar6811
@madipallynaveenkumar6811 5 ай бұрын
Nice one!... Liked it!
@SR-zi1pw
@SR-zi1pw Жыл бұрын
Great tutorial brother
@zuperhache
@zuperhache 8 ай бұрын
by the way, what is your opinion on AI, copilot for example, Is it worth it to keep learning how to code?
@smurffronda2951
@smurffronda2951 Жыл бұрын
Thank you!
@RobinsonDomingo-dy7xq
@RobinsonDomingo-dy7xq 7 ай бұрын
do you have tutorial that all hook can be use?
@Smartroid
@Smartroid Жыл бұрын
can u also make a video on how react re-renders when usestate state is changed and how does useState use object.is() under the hood
@cosdensolutions
@cosdensolutions Жыл бұрын
That's a bit of an advanced topic 😅 I'm still doing beginner videos so it'll take some time!
@amalikmuhd
@amalikmuhd 11 ай бұрын
well explained!!
@clintonboamah6029
@clintonboamah6029 8 ай бұрын
Fantastic!😉
@amalkhardli
@amalkhardli 11 ай бұрын
great thank you!
@rklintwo
@rklintwo Жыл бұрын
Solid tutorial. New subscriber here!
@ariandane7631
@ariandane7631 Жыл бұрын
Thank you. Why wouldn’t you just set a variable count and have a function that adds 1 and have the button call the function? I’m new to react and use state.
@cosdensolutions
@cosdensolutions Жыл бұрын
because in React components, doing it that way wouldn't cause a re-render and your new value wouldn't show on the screen! You need state to trigger an update and then it will show!
@tufanalin
@tufanalin 7 ай бұрын
Man I feel like Luka Doncic is teaching 😂
@Adam-zg7cv
@Adam-zg7cv 7 ай бұрын
I suggest editing this video and adding an important concept. For example, why do you need the hook in the first place? I mean why don't you just use a JS variable instead? setState causes the whole component to be re-rendered. You cannot fully understand without fully understanding the component lifecycle.
@prithivirajanv8146
@prithivirajanv8146 Жыл бұрын
hi, thanks... You are awesome... Make more videos
@cosdensolutions
@cosdensolutions Жыл бұрын
Will do!
@webb-developer
@webb-developer 9 ай бұрын
what's the different between using a state and using a normal variable and reassigning it ?
@cosdensolutions
@cosdensolutions 9 ай бұрын
State triggers a re-render of the component so you can see the new value in the UI, variable assigning will not work consistently in React
@sheshankkumar1184
@sheshankkumar1184 Жыл бұрын
Can you please make one video where we get to know difference between using useState hook instead of normal variables using let keyword
@cosdensolutions
@cosdensolutions Жыл бұрын
you should always use state for things that you want to track and update over time. The only use case for using something like a variable without state is when you want to derive something from state. But everything should be driven from state in React
@sheshankkumar1184
@sheshankkumar1184 Жыл бұрын
understood but what happens when i use normal variables instead of State variables? I can use them seamlessly. While using state variables I face difficulty as they require a queue to call set functions. that is not the case with normal variables.
@unucooper3602
@unucooper3602 4 ай бұрын
thank uuu
@avinashshiyani
@avinashshiyani 10 ай бұрын
Nice
@farahelaydi8474
@farahelaydi8474 Жыл бұрын
thank Youuu
@kaptainfreak6988
@kaptainfreak6988 11 ай бұрын
thank u
@yousufrumi5587
@yousufrumi5587 4 ай бұрын
zoom in your code screen
@itxchiii
@itxchiii Ай бұрын
whole lotta capping in the intro, the video is clear but thats not everything about useState().
@Abc-me2cx
@Abc-me2cx 9 ай бұрын
hello
@ariyoujahan9662
@ariyoujahan9662 Жыл бұрын
I love your videos, but i actually disliked this one. It wasn't like your other videos. Watching all those amazing video that covers every corners and addresses all edges cases made an expectation. But nuh, this wasn't one of those. Hope your create another video and address those as well. By the way thank you.
@cosdensolutions
@cosdensolutions Жыл бұрын
This is my first ever video my dude ☺️
@userre85
@userre85 7 ай бұрын
He didn't introduce the setState(prev => prev+1) syntax
@7VoltZone
@7VoltZone Ай бұрын
okay, the title said it "simply", I dont know that its really mean SIMPLE! and you said the last useState video, wich is NOPE... You just explain like 50% of useState.. what useState could do? what it used for? can you explain how to call count without arrow function? how I can check the count's current value? maybe some conditional logic? you just tell us something that already writen in the reac's docs...
@sachinkhatri1077
@sachinkhatri1077 4 ай бұрын
Hello sir i have double. Why can't we use count++ instead of count + 1 ????
@shaxzodsharipov6622
@shaxzodsharipov6622 Жыл бұрын
admin, i heve best offer for you . How can we talk
@cosdensolutions
@cosdensolutions Жыл бұрын
Discord
Learn React Hooks: useEffect - Simply Explained!
14:07
Cosden Solutions
Рет қаралды 166 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 112 М.
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН
Top 6 React Hook Mistakes Beginners Make
21:18
Web Dev Simplified
Рет қаралды 581 М.
3 Beginner React Mistakes That Can Ruin Your App
20:19
Web Dev Simplified
Рет қаралды 106 М.
Learn React Hooks: useReducer - Simply Explained!
13:48
Cosden Solutions
Рет қаралды 67 М.
Learn React Hooks: useContext - Simply Explained!
15:46
Cosden Solutions
Рет қаралды 185 М.
Learn React Hooks: useMemo - Simply Explained!
13:41
Cosden Solutions
Рет қаралды 112 М.
React useState() hook introduction 🎣
16:33
Bro Code
Рет қаралды 34 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 488 М.
Learn useState In 15 Minutes - React Hooks Explained
15:45
Web Dev Simplified
Рет қаралды 1,2 МЛН
Learn React Hooks: useLayoutEffect - Simply Explained!
9:17
Cosden Solutions
Рет қаралды 20 М.
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24