Тёмный

Learn useState In 15 Minutes - React Hooks Explained 

Web Dev Simplified
Подписаться 1,6 млн
Просмотров 1,1 млн
50% 1

🚨 IMPORTANT:
Full React Course: courses.webdevsimplified.com/...
In this video I cover everything you need to know about the useState hook. I also go over the basics of hooks as well so you can start using hooks in your own projects. This is the beginning of a series of React videos where I cover all the important hooks in React.
Skip Past General Hook Details: 4:22
📚 Materials/References:
useState Blog Article: blog.webdevsimplified.com/202...
React Hooks Playlist: • React Hooks
🧠 Concepts Covered:
- How to use hooks in React
- How to convert class state to function state with useState
- How to use the useState hook
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
#ReactJs #WDS #useState

Опубликовано:

 

2 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,2 тыс.   
@Brian-og6kk
@Brian-og6kk 3 года назад
Just wanted to say I'm a 39 yo man who currently enrolled into a school for software engineering. I often refer to your videos, and they have helped me maintain a perfect score so far in school. Thank you so much for these!!!!
@dangeorge3826
@dangeorge3826 3 года назад
How is it going, man? Have you found a job?
@Brian-og6kk
@Brian-og6kk 3 года назад
@@dangeorge3826 not yet, currently finishing up my portfolio now. Hope to have it done this week. But, I was able to help my friend who I met in this class to land a job. He had no prior coding knowledge. It's very possible. Super excited for him.
@dangeorge3826
@dangeorge3826 3 года назад
@@Brian-og6kk and how old is him?
@Brian-og6kk
@Brian-og6kk 3 года назад
@@dangeorge3826 he is 37
@dangeorge3826
@dangeorge3826 3 года назад
@@Brian-og6kk lol, congrats to him and good luck to you, man. I am 26, i am coding frontend for about 6 months and I am afraid that I will not get a job this year 😂
@amantech683
@amantech683 3 года назад
my name is kyle and my job is to simplify the web for you so that u can start building your dream projects sooner .....I love this sentence
@HoldenMadagameTenor
@HoldenMadagameTenor 3 года назад
How is it possible for you to explain something in 15 minutes that I didn't understand from hours of watching other videos? You've seriously got a gift for teaching, and I feel like I have a much better comprehension of useState now. Thank you!
@lyawileh.a8741
@lyawileh.a8741 3 года назад
Sure.
@george527
@george527 3 года назад
148k people needs a 15min video for a 5 min documentation read?
@timzeynalov3537
@timzeynalov3537 3 года назад
look at the documentation on www.Reactjs.org and make same things
@HoldenMadagameTenor
@HoldenMadagameTenor 3 года назад
@@george527 How edgy shaming beginners for understanding something better from this video. So cool and edgy wow.
@george527
@george527 3 года назад
:))) imagine being called "edgy" for telling them that they can do it faster by reading. Im 100% sure no beginner was thinking: "This anonymous guy from RU-vid with a stupid Icon made me feel ashamed that I watch videos"
@pauljmorton
@pauljmorton 3 года назад
Finally somebody actually explained what the hell the "const [thing, otherthing] = stuff" syntax actually does, instead of saying "it's just some ES6 magic syntax".
@emgodas
@emgodas Месяц назад
Who say's it's just some es6 magic syntax? I've never hear it from anyone here on RU-vid
@pauljmorton
@pauljmorton Месяц назад
@@emgodas My description of it being described as "just some es6 magic syntax" stemmed from the frustration of countless other tutorials going "just write this, you don't need to understand what this syntax means, just write it like this and it'll work" and not explaining it.
@masonmarinko6548
@masonmarinko6548 3 года назад
This was amazing, getting into react for last part of our boot camp and it goes so fast they don't always go in depth, this made sense, and has helped me a LOT, thank you so much!!
@battmarn
@battmarn 3 года назад
This was such a good tutorial. It actually explained everything methodically and using simple examples, without treating the viewer like an idiot. I love this channel.
@nowthisisfuuun
@nowthisisfuuun 2 года назад
Man, I don’t think there’s anyone who can explain concepts as simple and eloquent as you. Absolutely love your work!
@narasimhakamath3808
@narasimhakamath3808 2 года назад
Really love how you take some really simple example to explain these concepts instead of overthinking or over complicating things. Awesome stuff!
@LanguageSkillz
@LanguageSkillz 2 года назад
10:57 highlight for running vs referencing any initial function is so nice. Also appreciating the attention to variable de-structuring syntax, way beyond notation purposes, as noticed below.
@Alanm1963
@Alanm1963 3 года назад
I've been using react for over 4 years and off course am very comfortable with class components. Am currently adding to an existing application and decided to see what all the fuss was with functional components and hooks. Your 15 minutes on the nuance of basic concepts behind setState has been very helpful. Good video.
@alanespinet8423
@alanespinet8423 3 года назад
Best explanation I have seen so far about useState, and you do a fantastic job explaining even the edge topics like hooks order, fragmented state, etc. I really loved this video, man. Subscribed!
@flexrumblecrunch9140
@flexrumblecrunch9140 2 года назад
Your teaching skills are so well adapted to abstract concepts like coding. I think that you've got a real knack for addressing the questions that naturally pop into people's heads as they grasp this content, nice work! This cleared up a lot of things for me in such a short amount of time, easiest sub of my life.
@dominicnzl
@dominicnzl 4 года назад
Thanks for the explanation, it's very easy to follow this way. I must admit I laughed at the typo at 5:57 but you recovered nicely
@errol1494
@errol1494 3 года назад
I came here to say this. He kept his poker face. Good job, Kyle!
@cool1010com
@cool1010com 3 года назад
Hey, who does not want to decrement a c*nt ?
@calebbeers6384
@calebbeers6384 3 года назад
As soon as I saw that, I minimized the video to scroll down and read the comments.
@stefanpop2257
@stefanpop2257 3 года назад
I decremented the screen to look for this comment as soon as I saw the typo..
@kim_nguyen_
@kim_nguyen_ 2 года назад
it happened to me once in a CCNA course when I typed no shit instead of no shut in front of my professor...
@donmikele07
@donmikele07 Год назад
SMAL NOTE: 10:53 if you call function by reference, so "useState(countInitial)", so WITHOUT BRACKETS, the function will be called only once. Greate tutorial, great explanations, great teacher! Keep going!
@BenMatthewsMusic
@BenMatthewsMusic 2 года назад
Absolutely fantastic. So clear and helpful. So few guides take the time to go through various similar-but-different approaches to use cases, and don't talk much about why or when it's important to choose one over the other. Thank you!
@hellosugaree
@hellosugaree 3 года назад
Brilliant as always. These narrow topic mini videos have become an essential tool for filling in gaps where I need to learn the why behind the how. 💜
@shawnxia3874
@shawnxia3874 3 года назад
Havn't seen a guy who explains useState better than you. Subscribed.
@irieyaadricx1384
@irieyaadricx1384 4 года назад
I appreciate the explanation of the overlooked things that are usually.. 'Just done this way'
@c0nsumption
@c0nsumption Год назад
The tip you gave on function initialization for use state is phenomenal. I boosted performance drastically in my application 😯
@marineoceania
@marineoceania 2 года назад
As a veteran JS user for YEARS, I needed a crash course in React; your videos have been INCREDIBLY helpful! Thanks for doing this :D
@BJAnderson
@BJAnderson 2 года назад
Today was one of those days where I needed to learn something new, and instead of searching for hours... First search, first click, and 15 minutes later - learning accomplished. Thank you very much. Great tutorial!
@sethmccullough6206
@sethmccullough6206 4 года назад
You've got a phenomenal teaching style, Kyle. I can tell you always put in the time for proper preparation for your videos by how structured and easy to comprehend they are. As always, another excellent video, thanks!
@WebDevSimplified
@WebDevSimplified 4 года назад
Thank you! I actually wrote an entire blog article for this video first before recording to help make sure I has covered everything I needed to.
@a.yashwanth
@a.yashwanth 3 года назад
@Jimmy Kristian where is your second account which will confirm it worked?
@sulochanakharat9033
@sulochanakharat9033 2 года назад
@@WebDevSimplified sir I like your good keep going but please make vedio on all 10 react hooks
@Winter_Wyvern1
@Winter_Wyvern1 2 года назад
@@sulochanakharat9033 u dont need to write in broken english if u are to become a developer. Be smart!
@rrgeyddhdyr3373
@rrgeyddhdyr3373 Год назад
ru-vid.comluwxDqy6NC0
@iangibblet8165
@iangibblet8165 3 года назад
Great video! No guff, quality content that gets the concepts across with simple yet effective examples.
@ifereokibe9146
@ifereokibe9146 4 года назад
Your clarity in explaining things is second to none....Great one
@kasuneranda8192
@kasuneranda8192 Год назад
0% nonsense. 100% useful information. Awesome explanation!
@TheRealKitWalker
@TheRealKitWalker 3 года назад
And I thought spending 15+ mins on just useState was an overkill. It was SOO WORTH IT!! loved the way you explained it all with appropriate examples. Thanks a lot Kyle. ✌️😎👏👏🌹
@jibreelkeddo7030
@jibreelkeddo7030 3 года назад
You are one of the absolute *best* dev tutorial channels out there. Please never change!
@mikerivera3578
@mikerivera3578 3 года назад
Thanks so much for this Kyle! Most clear explanation of useState along with a few little tidbits of info that helped me understand its benefits! You're the man!
@konamax9
@konamax9 2 года назад
Nicely done sir. Taking complex subjects and simplifying them so that a child could understand them is no easy feat. Seriously, people that can do that are the ones that lower barriers and allow new people into areas they might otherwise not venture. They demystify. You truly do have a gift and I very thankful for people like you.
@MichaelCampbell01
@MichaelCampbell01 4 года назад
Oh, man, of all the typos you could have made, you made that one =D Great vid; well presented as always.
@suryasuresh9330
@suryasuresh9330 3 года назад
Haha i bet his heart dropped after typing that by accident XD
@farhanaditya2647
@farhanaditya2647 2 года назад
Timestamp?
@naruchancutie1
@naruchancutie1 2 года назад
@@farhanaditya2647 5:57
@victorejiofor8115
@victorejiofor8115 2 года назад
You made the useState hook so simple to understand you are really a good teacher. Please keep making more videos, thanks so much, I do appreciate it.
@SARAH-vh7jg
@SARAH-vh7jg Год назад
This is actually the best video to understand useState Hook. Everything is crystal clear! Thank you so much!
@bossbrackets8928
@bossbrackets8928 4 года назад
KYLE IS THE MAN!
@BryantCabrera
@BryantCabrera 4 года назад
You are such a good teacher Kyle. Thank you! You’re also so handsome 😊
@kennyliard5295
@kennyliard5295 3 года назад
You are so great! You really make web dev simple! Never understood useState until now. All of your lessons are so great, keep on the good work!
@TheUrgleBurgle
@TheUrgleBurgle Год назад
I’m in a coding bootcamp right now and you are a godsend! Thank you for your videos. They help so much!
@420Sumanta
@420Sumanta 2 года назад
This was awesome. I never knew about passing a function to useState to optimize the performance.
@GG-uz8us
@GG-uz8us 2 года назад
I wonder why though. Function in JS is higher-order function, can be used as variable. Why here is different?
@donner7708
@donner7708 3 года назад
that missed "o" though. Rough buddy. But an amazing video that helped me a lot! Thank you!
@brownboyintokyo7368
@brownboyintokyo7368 3 года назад
15mins of pure gold!!!!!! cleared my doubts completely
@HannahSchzde
@HannahSchzde 4 дня назад
I love how clearly you explain everything, it really reflects your knowledge on the topic! TYSM!
@jpf338
@jpf338 3 года назад
5:56 lol Great video by the way, thanks a lot!
@nanonkay5669
@nanonkay5669 4 года назад
Bro this video is made in Heaven, we needed this. Hooks are kinda confusing e.g. every time a component renders, it happens twice ( console.logs at 10:07 and 10:59). But hooks like useRef, useEffect and useCallback are the one's that confuse me the most
@kiyotaka721
@kiyotaka721 3 года назад
the double console.log happens with class components as well the reason is when u use create-react-app it by default uses strictmode which runs your code twice to debug it to remove go to index.js file and remove react.stricmode enclosing the app component
@miguelrivas9687
@miguelrivas9687 3 года назад
@@kiyotaka721 some new I learned, thanks.
@hipH0p5tr3ss
@hipH0p5tr3ss Год назад
This is the clearest, most concise explanation of the useState hook that I have found, HANDS DOWN. Thank you!
@izzy24x73
@izzy24x73 Год назад
This is absolutely the best explanation of React Hooks {useState}. I was struggling a lot not getting the correct understanding of this es6 style syntactic sugar.
@issamassafi
@issamassafi 4 года назад
Can we have a video about custom hooks? thank you for the effort
@kautukkundan8001
@kautukkundan8001 4 года назад
😍 nice! Please do one on the context API
@WebDevSimplified
@WebDevSimplified 4 года назад
Thanks! That will be coming for sure.
@jasonl5251
@jasonl5251 2 года назад
This video is brilliant! Detailed useState explanation in a simplified manner with examples.
@theoneandonlywoo846
@theoneandonlywoo846 3 года назад
You have a great knack, for simplifying a subject, thank you, concise and well presented!
@elinathancohen1723
@elinathancohen1723 3 года назад
That was a brilliant explanation, the only thing I don't understand is how does prevState gets the current state values :/
@LELEFO
@LELEFO 2 года назад
Yes! I am wondering the same thing!
@LELEFO
@LELEFO 2 года назад
Ah! I thought about it some more. When he destructured the useState hook and passed it the value 4, it was assigned as the current state and also passed to the setter function. I think that’s how it works
@ArvindHaran
@ArvindHaran 2 года назад
I think the second function that useState returns, such as setCount, setState etc. can take in a function and apply that function to the current value of the "state" (eg count) that it is bound with. So when saying prevCount => prevCount + 1 , you're just creating an anonymous function inline that takes an argument (prevCount) and increments it. The argument prevCount (or whatever else you rename it) is always passed in the current value of the state it is bound to in the useState call.. try renaming prevCount to xyz and reexecute
@prometheus2625
@prometheus2625 2 года назад
I had a hard time to understand this too. Still don't get it fully but I found that setState() is asynchronous and React may batch multiple setState() calls into a single update for performance(src: Reactjs.org). So, prevCount is just a function parameter received and it is the initial state on the first call. setcount(function(prevCount) { return prevCount - 1; }); Without using a function call inside setCount, you actually update the state directly, but with the function call you use a variable(function parameter) which is the returned value minus one and this value(variable) is used inside setCount() to set the state. I was experimenting with the following code and it give the same result. const [count, setCount] = useState(4); const x = count; function decrementCount() { setCount(function(x) { return x - 1; }); setCount(function(x) { return x - 1; }); }
@daviidon
@daviidon 3 года назад
at 10:50 , you can pass the function literal into setState and it will have the same behavior as the anonymous function.. So do UseState(countInitial) instead of UseState(countInitial()).
@exodion4173
@exodion4173 3 года назад
Can u explain or refer to the concept on how this work ? Dont we have to call the function to run it ?
@muhammadsalmankhan9326
@muhammadsalmankhan9326 3 года назад
@@exodion4173 yes you do not have to call it .. when we pass a function to useState like this => useState(() => {}) .. you can see we are only passing a function to useState not calling it
@marvinfok65
@marvinfok65 2 года назад
This is so clear! I had trouble understanding the useState concept from other medias!
@reinaogo7161
@reinaogo7161 2 года назад
just love your teaching style, easy to understand , relaxed, focus on what we need.
@silentxcure
@silentxcure 3 года назад
everytime you say gotchu, i wanna say bless you lol.
@ThatBritishVlogger
@ThatBritishVlogger 3 года назад
You know its been well explained, if I commented. I commented.
@Ahmed-mo7bg
@Ahmed-mo7bg Год назад
that was 15 min worth a whole week searching and watching multiple videos on the subjsct. thanks a lot and keep on the road simplifiying stuff...
@Holden_P
@Holden_P 2 года назад
Super helpful for me, and I am a senior dev team lead in OO programming (C#, WPF, MvvM) attempting to pivot back into web dev after about 2.5 years away from React. Trying to brush back up on it. Thank you so much for your clear explanation and no frills approach. Great stuff bud
@bernhardsmuts2265
@bernhardsmuts2265 3 года назад
Amazing! I find it strange that half this stuff isn't in the ReactJS docs, or is just really hard to spot, I tried to reference it and can't even find it... Amazing videos, as always!
@abdur1996
@abdur1996 3 года назад
Note to everyone: if you were updating the state using `setTimeOut`, remember closures in JS and know that it will get the state that you pass in at the time of you calling set timeout, as oppose to the current state of the useState hook. If you'd like setTimeout to use the newer state, you can wrap your state in a `useRef` container and it's `.current` property will hold the latest state.
@kashmirtechtv2948
@kashmirtechtv2948 2 года назад
Great. Can you elaborate?
@dardanillyr3989
@dardanillyr3989 2 года назад
Could i Ask for help regarding something in react?
@jofawole
@jofawole 11 месяцев назад
Thanks so much for this very clear and understandable video, I've been playing with React lately and your video made me understand useState more perfectly.
@nightzero6040
@nightzero6040 3 года назад
I've seen many videos trying to explain state() hook and for me and that is the only video I could really understand properly! Thank you very much!!
@mekelilyasa9561
@mekelilyasa9561 3 года назад
decrement what?
@mtsurov
@mtsurov Год назад
@ 7:45 can somebody educate me on the setCount (prevCount => prevCount - 1) ? its unclear to me how prevCount was assigned value of 4.
@lukas.webdev
@lukas.webdev Год назад
4 is our initial state that we added 3 rows above by saying useState(4)... so our counter starts with an initial value of 4. Every time you increment or decrement the counter, this component gets re-rendered and prevCount just takes the current count value and increments or decrements it... I don't know if this answer was very helpful... but I just posted a video about the same topic, check it out and maybe this will help you to understand it... 😉
@collinsadhola8278
@collinsadhola8278 3 года назад
Great explanation. I cant believe how simple you made this seem. I was scratching my head over the concepts involved before coming across this video.. Thanks
@Juzzyjuzzy
@Juzzyjuzzy 2 года назад
That was excellent! It was concise. I like you provided different options for incrementing and decrementing the counts.
@ashmitsharma9096
@ashmitsharma9096 Год назад
5:55 there are no accidents
@Cypekeh
@Cypekeh 11 месяцев назад
freudian slip
@arjunkashyap8896
@arjunkashyap8896 4 года назад
Before watching this video, I thought I understood the react hooks..
@shivanigaddagimath6105
@shivanigaddagimath6105 3 года назад
Hi Arjun! Are you a student or working currently? Would you be interested to explore job opportunities in web development?
@arjunkashyap8896
@arjunkashyap8896 3 года назад
@@shivanigaddagimath6105 No, thank you.
@goon3305
@goon3305 3 года назад
beat my head against the wall all day for trying to learn this hook. this summed everything up in such a concise way! so grateful, keep up the amazing work.
@Misfittykitty
@Misfittykitty 2 года назад
You, young man, are a masterful teacher! Thank you for making this complex topic simple and accessible to all. This is the mark of a great educator. :) :)
@liammcbride9210
@liammcbride9210 2 года назад
Was really struggling with some hook tutorials but this certainly helped, great video!
@CamKnoppMusic
@CamKnoppMusic 3 года назад
Thanks! I'm currently making my way through FullStackOpen and this helped a lot.
@DennisJadeToribio
@DennisJadeToribio 3 года назад
I love the style of delivery and the direct way to hitting the topic and time....thanks
@RockstahRolln
@RockstahRolln 3 года назад
This is absolutely brilliant!! So thoroughly explained! Excellent video on React Hooks.
@nitishvirtual4745
@nitishvirtual4745 11 месяцев назад
Explained the concept really well and covered all the bases. Thank you!
@HadesMrDark
@HadesMrDark 2 года назад
I was trying for a long time to understand how these hooks work, thank you soo much, great video, great explanation.
@krissymorgan6602
@krissymorgan6602 3 года назад
Very very clear. I have searched so much content on this but I still didn't have a very clear understanding on how to use it. You really helped me a lot thanks.
@jazzscorner
@jazzscorner 3 года назад
bless you for this tutorial! the react site was way too simple yet complex but this explains it all!
@bozkurt6264
@bozkurt6264 4 года назад
You are the King, I was looking for such an awesome React.js Hooks course but have not found the nice one till i saw your "useState" video
@mid9639
@mid9639 2 года назад
I couldn't understand this thing for weeks...you did the magic in 15 mins... Man !!! Some people are born to be good teachers ❤️ teaching someone or passing your knowledge to others , is one of the most noble thing to do ❤️
@silverunicorn8228
@silverunicorn8228 8 месяцев назад
Kyle, thank you so much! Info about previous state (prevCount in your example) was crucial to me.
@markusbatlogg4345
@markusbatlogg4345 3 года назад
The perfect react-course. Very well explained, good examples, really well done Thank you
@clutchmadness
@clutchmadness 2 года назад
Wow! This is explanation is both thorough and simple.
@jadekinstudio
@jadekinstudio 3 года назад
Thank you! I was struggling with this today in a new project and now it makes sense :)
@karlinataurina.4119
@karlinataurina.4119 Год назад
You explain things so well! Thank you!
@GuitarreroDaniel
@GuitarreroDaniel 3 года назад
Man this was amazing, I took an Udemy course and read some posts but I didn’t get this until this video of yours.
@rushabhpatel2655
@rushabhpatel2655 2 месяца назад
So clear explanation. Loved the video. Keep up the good work brother.
@mattkleczewski2926
@mattkleczewski2926 2 года назад
Great video! You really did a great job of describing the important parts of this!
@Applestaffman
@Applestaffman 2 года назад
The coolest teaching style that i have EVER seen!!
@alishachhetri2351
@alishachhetri2351 2 года назад
I'm new to web development, just shifted from working in design to development. This video was really helpful, you really simplified it. Excellent teaching style, subscribed.
@serhiidmitriiev4362
@serhiidmitriiev4362 Год назад
Man, I'm really impressed by the way you explain the topic! I came to your tutorial from udemy where the guy explained the very same topic but in a cumbersome way! Thanks a lot!
@sumayaNoman
@sumayaNoman 2 года назад
Thank you soooo much I have been struggling to understand the useState hook but you explained it in a way that made it soo simple, thanks a lot !!!!
@pedrambabazadeh1676
@pedrambabazadeh1676 2 года назад
One of the greatest tutorials I have ever seen! Thank you.
@edappalkkaran
@edappalkkaran 3 месяца назад
so easy explanation and in in-depth, i think. kudos.
@thecodelife9855
@thecodelife9855 2 года назад
Not everyone can explain something effectively, but u do it well. Good work. I just started learning React and it is very complex , but ur video helps.
@aishwaryas8283
@aishwaryas8283 4 месяца назад
Thank you for the clear and precise explanation!!
@sogenohata1948
@sogenohata1948 Месяц назад
Wow. I was a little confused when I was reading a textbook on useState. But now it's so clear. Thank you so much!
@bim_rai
@bim_rai Год назад
Helped me understand immensely versus the Meta course I am learning from! Thank you!
@shaun374
@shaun374 2 года назад
Thank goodness there's actually someone who takes time to explain wtf is going on in code. So many tutorials are just people flying through examples and not explaining or showing how things work at all.
@lambar0
@lambar0 Год назад
Comprehensive explanation with intuition developed around hooks
@thatsgoodkarma
@thatsgoodkarma 2 года назад
Oh man, I think you just taught me how to get around the useState issue I've been slamming my head against as a React newbie. This is great! Thank you!!
@IAmIndraTheGod
@IAmIndraTheGod Год назад
Your explanation is very intuitive, thanks for this video
Далее
Learn useEffect In 13 Minutes
13:38
Просмотров 807 тыс.
Learn useMemo In 10 Minutes
10:42
Просмотров 462 тыс.
МАЛОЙ ШАНТАЖИСТ
00:34
Просмотров 78 тыс.
React JS - React Tutorial for Beginners
2:25:27
Просмотров 6 млн
Learn useRef in 11 Minutes
10:20
Просмотров 614 тыс.
Learn useReducer In 20 Minutes
20:12
Просмотров 487 тыс.
Learn useContext In 13 Minutes
13:08
Просмотров 691 тыс.
React Hooks Course - All React Hooks Explained
1:26:21