Learn React Hooks: useState - Simply Explained!

  Рет қаралды 41,992

Cosden Solutions

Cosden Solutions

Күн бұрын

Join The Discord! → discord.cosdensolutions.io
Source Code → github.com/cosdensolutions/co...
In this video we will learn about React hooks, starting with useState. This powerful React hook will allow you to have state inside of functional components, and will allow you turn your static React applications into stateful ones. You will learn how to create state, how to set a default value, and how to update the state using useState in React.
In this new React world, hooks are here to stay, so it's best to learn them! In this tutorial I demonstrate the useState React hook, and I explain it very simply and in a way that is easy to understand. Enjoy!
Subtitles by Naveen G

Пікірлер: 78
@cosdensolutions
@cosdensolutions 3 ай бұрын
Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react
@percyk6884
@percyk6884 7 ай бұрын
Simple, quick, and efficient, thank you!
@bbbeo8912
@bbbeo8912 5 ай бұрын
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.
@richardclifford583
@richardclifford583 6 ай бұрын
Very simplified explanation! Thanks!
@rinshadrinshad3540
@rinshadrinshad3540 9 ай бұрын
Simple and detail Thanks For The Effort 🙌
@zuperhache
@zuperhache 3 ай бұрын
finally !! after watching 1000s of videos, a dude that explains! clearly how the hooks work, thank you ! 🙏💪
@Nelson-fw5ly
@Nelson-fw5ly 8 ай бұрын
so because of useState(), I can click the 'Like' button on this video and the like counter can increment? 😆
@cosdensolutions
@cosdensolutions 8 ай бұрын
Hahahaha yes exactly ☺️
@bbbeo8912
@bbbeo8912 5 ай бұрын
Then click on it again to test the decrement :)) Lol j4f don't do that haha
@FursMars
@FursMars 8 ай бұрын
You are the best teacher! Thank you for you real help and your tami and work!!!
@janemisshela
@janemisshela Ай бұрын
You simplified the complexity of this concept! Thanks so much!
@alissoncamoes7113
@alissoncamoes7113 9 ай бұрын
thank you for sharing, greetings from Brazil!
@TEScompetitive
@TEScompetitive 7 ай бұрын
Much appreciated, best tutorial out on this
@tea2125
@tea2125 3 ай бұрын
You are an amazing teacher! Thank you!
@mustafacoskun5208
@mustafacoskun5208 6 ай бұрын
Thanks for clear and to the target explanation...
@eunwoooscomics
@eunwoooscomics 8 ай бұрын
I loved this video keep up the good work
@sarahwbas
@sarahwbas 3 ай бұрын
Thank You so much! your channel is underrated!
@rohitindurke3549
@rohitindurke3549 Ай бұрын
Really, this was my last tutorial for using the state hook. Thanks for your effort.💗
@narcleptik
@narcleptik 6 ай бұрын
Thank You, you are a good teacher.
@Electro_69
@Electro_69 Ай бұрын
Daaaaamn you are a god or what, i wasted my 5 hours on this and you taught me in 10 minutes, salute man
@OXIDE777-is6gs
@OXIDE777-is6gs Жыл бұрын
Awesome!!! please do more of those on other React subjects🙏
@cosdensolutions
@cosdensolutions Жыл бұрын
Yep 🤙
@SR-zi1pw
@SR-zi1pw Жыл бұрын
Great tutorial brother
@rklintwo
@rklintwo Жыл бұрын
Solid tutorial. New subscriber here!
@priyamjain01
@priyamjain01 Ай бұрын
You are a saviour my friend 🙏
@boukrimohammed
@boukrimohammed 3 ай бұрын
i swear you're a life saver
@rusliabdulgani9920
@rusliabdulgani9920 6 ай бұрын
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 6 ай бұрын
so if there is any recent value involve, please make sure using this approach (using callback), rather than directly inject state
@jasonadams1876
@jasonadams1876 20 күн бұрын
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.
@madipallynaveenkumar6811
@madipallynaveenkumar6811 3 күн бұрын
Nice one!... Liked it!
@Adrianku
@Adrianku 6 ай бұрын
just WOW! this was really helpful! thanks! new sub here
@jabiesorenson8271
@jabiesorenson8271 4 ай бұрын
Just subbed cause I like the way you describe things good job
@andrewchukwudumeje9413
@andrewchukwudumeje9413 2 ай бұрын
I love the explanation bro Thanks a lot Keep up the good work
@Salah-YT
@Salah-YT 10 ай бұрын
Lovely job, bro! Subscribed and liked. Please cover each hook individually and create a list, it would be awesome. Thanks a lot! 😍👍
@cosdensolutions
@cosdensolutions 10 ай бұрын
There's a playlist already ☺️ but yes planning to do all of them
@manushadananjaya8125
@manushadananjaya8125 9 ай бұрын
Thank you soo much this is so much better 😍
@cosdensolutions
@cosdensolutions 9 ай бұрын
glad you found it useful!
@amalikmuhd
@amalikmuhd 6 ай бұрын
well explained!!
@GeraldPajulas
@GeraldPajulas 5 ай бұрын
Thank you for this. I understand the useState now hahaha😆😆
@clintonboamah6029
@clintonboamah6029 3 ай бұрын
Fantastic!😉
@smurffronda2951
@smurffronda2951 7 ай бұрын
Thank you!
@amalkhardli
@amalkhardli 6 ай бұрын
great thank you!
@Scotthutchinsonking
@Scotthutchinsonking 6 ай бұрын
this dude is awesome
@kristiankristian4652
@kristiankristian4652 6 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
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.
@RobixYTT-nu4ug
@RobixYTT-nu4ug 6 ай бұрын
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!
@renejacques8288
@renejacques8288 4 ай бұрын
I guess you were right; I do have a better understanding of useStates now. What gets me is the word interface you used.
@TheHumanistX
@TheHumanistX 9 ай бұрын
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 9 ай бұрын
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
@manushadananjaya8125
@manushadananjaya8125 9 ай бұрын
Greetings Good luck! From Sri lanka❤
@cosdensolutions
@cosdensolutions 9 ай бұрын
thank you! love sri lanka :D colombo is a great city
@prithivirajanv8146
@prithivirajanv8146 Жыл бұрын
hi, thanks... You are awesome... Make more videos
@cosdensolutions
@cosdensolutions Жыл бұрын
Will do!
@tufanalin
@tufanalin 2 ай бұрын
Man I feel like Luka Doncic is teaching 😂
@kaptainfreak6988
@kaptainfreak6988 5 ай бұрын
thank u
@avinashshiyani
@avinashshiyani 5 ай бұрын
Nice
@farahelaydi8474
@farahelaydi8474 11 ай бұрын
thank Youuu
@abzz1290
@abzz1290 6 ай бұрын
Great. How to handle multiple or object and array in useState?
@RobinsonDomingo-dy7xq
@RobinsonDomingo-dy7xq 2 ай бұрын
do you have tutorial that all hook can be use?
@zuperhache
@zuperhache 3 ай бұрын
by the way, what is your opinion on AI, copilot for example, Is it worth it to keep learning how to code?
@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!
@kadirmemisoglu343
@kadirmemisoglu343 7 ай бұрын
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
@webb-developer
@webb-developer 4 ай бұрын
what's the different between using a state and using a normal variable and reassigning it ?
@cosdensolutions
@cosdensolutions 4 ай бұрын
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
@ariandane7631
@ariandane7631 8 ай бұрын
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 8 ай бұрын
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!
@Adam-zg7cv
@Adam-zg7cv 2 ай бұрын
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.
@sheshankkumar1184
@sheshankkumar1184 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
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.
@Abc-me2cx
@Abc-me2cx 4 ай бұрын
hello
@ariyoujahan9662
@ariyoujahan9662 7 ай бұрын
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 7 ай бұрын
This is my first ever video my dude ☺️
@userre85
@userre85 2 ай бұрын
He didn't introduce the setState(prev => prev+1) syntax
@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
Рет қаралды 116 М.
Learn React Hooks: useMemo - Simply Explained!
13:41
Cosden Solutions
Рет қаралды 80 М.
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 19 МЛН
WHO DO I LOVE MOST?
00:22
dednahype
Рет қаралды 18 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 15 МЛН
Learn React Hooks: useContext - Simply Explained!
15:46
Cosden Solutions
Рет қаралды 129 М.
Learn useReducer In 20 Minutes
20:12
Web Dev Simplified
Рет қаралды 491 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Learn React Hooks: useReducer - Simply Explained!
13:48
Cosden Solutions
Рет қаралды 46 М.
UseState: Asynchronous or what?
17:00
Jack Herrington
Рет қаралды 64 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 455 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 80 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 412 М.
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 19 МЛН