Learn useEffect In 13 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024
  • 🚨 IMPORTANT:
    Full React Course: courses.webdev...
    1 Year Free Hosting: www.atlantic.n...
    Use code KYLE for an additional $50
    In this video I cover everything you need to know about the useEffect hook. I compare this hook to the old way of doing things with lifecycle methods in class components so you can understand how to start using hooks effectively in your projects. This is part of a series of React videos where I cover all the important hooks in React.
    📚 Materials/References:
    useState Video: • Learn useState In 15 M...
    useEffect Blog Article: blog.webdevsim...
    React Hooks Playlist: • React Hooks
    🧠 Concepts Covered:
    - How to use hooks in React
    - How to convert class lifecycle methods to function effects with useEffect
    - How to use the useEffect hook
    🌎 Find Me Here:
    My Blog: blog.webdevsim...
    My Courses: courses.webdev...
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/Web...
    CodePen: codepen.io/Web...
    #ReactJs #WDS #useEffect

ความคิดเห็น • 778

  • @ThatGuyAnonymous
    @ThatGuyAnonymous 4 ปีที่แล้ว +649

    You have the gift of breaking down any difficult topics in a way that everyone can understand.
    I wish there was a super like button on TH-cam 👍

    • @TheImprenditore
      @TheImprenditore 4 ปีที่แล้ว +9

      I thought so too, he can probably bundle this up and make it into an in-person bootcamp and charge 15k per head.

    • @underlecht
      @underlecht 3 ปีที่แล้ว +6

      yes, he is that guy.

    • @cba88
      @cba88 3 ปีที่แล้ว +4

      super like from here

    • @KanchanSharma-bg2yh
      @KanchanSharma-bg2yh 3 ปีที่แล้ว +8

      I saw many videos on hooks before, but this one only makes me understand completely in detail and in first attempt only. Thank you so much.

    • @deansprivatearchive
      @deansprivatearchive 3 ปีที่แล้ว +4

      The subscribe button.

  • @romaniecumtehului6792
    @romaniecumtehului6792 3 ปีที่แล้ว +403

    I paid money for a full react course on udemy and after every hook I "learn" from there, I come to your channel to see it reexplained better. 😅

  • @aaronmotacek9343
    @aaronmotacek9343 2 ปีที่แล้ว +414

    One note at 5:00 for people newer to React. If you try to update state with setState (setResourceType in this case), but the value is the same as the current state, it won't trigger a rerender. This is because of the way the React team has chosen to implement useState (it helps to prevent unnecessary rerenders). This can become an issue when your state is an array (or an object), as you can mutate the array, try to update state, and it may not trigger a rerender because React thinks the array is the same (since the array reference is the same). You can solve this issue by using the spread operator (...) to create a truly new array or object: setState([...array]) or setState({...object}). More info on that at if you Google something like "usestate update not always triggering rerender component"

    • @nemanjastankovic941
      @nemanjastankovic941 2 ปีที่แล้ว +9

      Thanks for this heads-up. It's something really useful to know

    • @prince5922
      @prince5922 2 ปีที่แล้ว +2

      Correction: if you use _setState_ it will always re-render.

    • @vapeurdepisse
      @vapeurdepisse 2 ปีที่แล้ว +9

      I found that out early on. There is this rule in React that "one simply doesn't mutate state" and it applies to hooks as well. React uses Object.is() to check for equality between the previous state and the new state, and if you mutate an array or object, it is still the same object and so it won't update.

    • @mrmartinwatson1
      @mrmartinwatson1 2 ปีที่แล้ว +1

      @@prince5922 no

    • @tmode9303
      @tmode9303 2 ปีที่แล้ว +1

      @@prince5922 No, it the value is same as before it won't re render. You need to spread

  • @michaelbarbarelli3764
    @michaelbarbarelli3764 ปีที่แล้ว +50

    The fact that the clean-up code runs before the event listener is a key point that's rarely communicated in docs, tutorials, etc. Very well done!

    • @lukas.webdev
      @lukas.webdev ปีที่แล้ว +1

      Yes, I agree 100%! 😉

    • @loneWolff1995
      @loneWolff1995 6 หลายเดือนก่อน +1

      Can you explain Two things why App being rendered twice, when you click post twice, I mean when you clicked first time, I understand app being rendered, but when you clicked again on Post.
      The app shouldn't get rendered as state is already same.
      Second why useEffect ran twice, even though you are not using StrictMode
      *Kindly help !!!!*

  • @learningdevelopment7429
    @learningdevelopment7429 4 ปีที่แล้ว +149

    You are incredible! I'm self taught and employed as a full stack engineer, so I've been able to find some high quality tutorials on my journey. But you my friend, are truly an incredible teacher on intermediate/advanced language topics and I hope you continue to keep making these vids!

    • @makanmusty
      @makanmusty 3 ปีที่แล้ว +5

      ditto man! hes a beast!!

  • @patricktkinter
    @patricktkinter 10 หลายเดือนก่อน +16

    I knew he was going to be good when he starred directly into my soul

  • @zentaitamas
    @zentaitamas 3 ปีที่แล้ว +33

    This is the most understandable explanation I’ve ever found. Good job mate and thanks.

  • @darwinduranalba2539
    @darwinduranalba2539 3 ปีที่แล้ว +24

    dude I wish I had met this channel sooner. You're amazing

  • @IMChristianLowe
    @IMChristianLowe 3 ปีที่แล้ว +22

    I'm primarily a backend/infrastructure dev and have been struggling with some very basic React concepts. I watched your useState video first and you did a fantastic job breaking it down and simplifying it so that my smooth brain could understand it. You've done a fantastic job here too. Well done!

    • @veoquenoesunproblema
      @veoquenoesunproblema 3 ปีที่แล้ว +2

      Man, I have the same issue, of course I'm just a student right not, but the useState was a killer video for me. With that video I understood a lot of react but this useEffect is mind blowing, really funny how a lot of people love React but it is kind of complex to get it when you advance to the second page which is like, man is this so freaking easy? hah

    • @alexcastro9157
      @alexcastro9157 2 ปีที่แล้ว

      @@veoquenoesunproblema That is because people are learning ONLY React, which relays on JS, pretty much.
      Good video, however this guy like almost ALL people try to assign the lifecycle to useEffect. But it is not pretty much the case because functional components behavior different from react classes, Dan explained in its blog ALL DETAILS.
      Also this guy does not talk about Closures and why it is important to know them... (Course because people do not learn javascript but react)....

  • @23Kattayopp
    @23Kattayopp 4 หลายเดือนก่อน

    Kyle, every single time I feel that I don't understand something as good as I'd want, either it's html/css/js or react, I go and search a video on that subject from you. It's been a year and a half and it worked every single time. And I want to thank you for that! You're awesome.

  • @KaranSharma-ew7io
    @KaranSharma-ew7io 3 ปีที่แล้ว +22

    Everything about you is cool , from hairstyle to voice to explanation

    • @gunnarMyTube
      @gunnarMyTube 3 ปีที่แล้ว

      Learn from the enlightened

  • @dimaster5880
    @dimaster5880 4 ปีที่แล้ว +33

    Wow, this is the best explanation I have ever seen so far. My respect.

  • @hniehslimi2894
    @hniehslimi2894 ปีที่แล้ว +1

    This is the most understandable explanation I’ve ever seen

  • @user-yz5hj3zg2x
    @user-yz5hj3zg2x ปีที่แล้ว +1

    FINALLY!! After reviewing a ton of tutorials and explanations, I could finally understand what this hook was for! Thanks a lot!

  • @cafuune
    @cafuune ปีที่แล้ว +1

    was struggling all day with this thing, now its like crystal clear lol thank youuuu

  • @BobbyBundlez
    @BobbyBundlez 3 ปีที่แล้ว +8

    wow. never seen state being used to fetch data dynamically like that with the press of one button! awesome!

  • @Hidiho2u
    @Hidiho2u ปีที่แล้ว +1

    I understand more in the last 30 minutes than I did 8 hours of lectures and workshops ago. Thank you so much!

  • @bigeddie1994
    @bigeddie1994 2 ปีที่แล้ว +1

    Any time I watch your videos, you connect the dots for me. Thank you for everything.

  • @riturathinsharma5931
    @riturathinsharma5931 4 ปีที่แล้ว +7

    You are a genius. The way you explain things and connect the dots is simply awesome. It is very easy to connect to what you explain and easily get accustomed to new technology . Great Going bro, keep it up :)

  • @tapstothebeat
    @tapstothebeat ปีที่แล้ว +1

    3 different YT videos taught me how to use the useEffect hook but I only learnt it when I saw your video.

  • @calarcher4869
    @calarcher4869 2 ปีที่แล้ว

    every video of yours i search for because I am trying to understand a seemingly impossible concept, I leave 15 minutes later having a great understanding. 100% live up to your name, Web Dev Simplified

  • @mashaisalive
    @mashaisalive ปีที่แล้ว +1

    один из немногих на ютубе, кто реально понятно объясняет. god bless him

  • @extrouzex1070
    @extrouzex1070 4 ปีที่แล้ว +2

    This guy is really awesome, talking too slowly but telling a lot of the topic for making it much easier, love u man 💚

  • @darkdevilxy457
    @darkdevilxy457 ปีที่แล้ว +1

    I have to say this is the best explanation of react hook

  • @Lingchao2596
    @Lingchao2596 ปีที่แล้ว +1

    One of the best tutorials ever

  • @marikabasagoitia6828
    @marikabasagoitia6828 ปีที่แล้ว +1

    As usual, thank you so much for your explanations. By far the best resource for web development on TH-cam!

  • @fithamlakfikrie4657
    @fithamlakfikrie4657 ปีที่แล้ว +1

    Thank you very much 🙏, It was a very clear explanation with sufficient but short examples.

  • @go_all_the_way
    @go_all_the_way ปีที่แล้ว +6

    you're a life saver and amazing teacher

  • @ThiagoVieira91
    @ThiagoVieira91 4 ปีที่แล้ว +23

    Hey Kyle thank you for this new series.
    I've been a rough time trying to study steadily while working from during this quarantine. This new series got me back on track. Waiting for the next episode!

    • @mohdsameer8899
      @mohdsameer8899 9 หลายเดือนก่อน

      What do you do now just curious 🧐

  • @manoranjands9479
    @manoranjands9479 ปีที่แล้ว +1

    Finally I understood the concept...wow what a way of teaching man...! So simple and understandable. Thank you so much

    • @lukas.webdev
      @lukas.webdev ปีที่แล้ว

      I agree! 😉

    • @user-gq1ij
      @user-gq1ij 11 หลายเดือนก่อน

      ​​@@lukas.webdevAt 10:00, how is useEffect called, even though the array is empty and having no change

  • @siddharthmehta6966
    @siddharthmehta6966 2 ปีที่แล้ว

    This is the best explanation one can get on internet !!!! Simply wow . Thanks for the tutorial

  • @niloben659
    @niloben659 ปีที่แล้ว +1

    Once again knocking it out of the ballpark

  • @millicentmalinga962
    @millicentmalinga962 6 หลายเดือนก่อน

    The name of the channel really speaks for itself. Thank you for this

  • @badrivelamurasokan837
    @badrivelamurasokan837 3 ปีที่แล้ว +1

    You definitely have the teacher mindset. Really clear!

  • @filipozbolt
    @filipozbolt 3 ปีที่แล้ว +1

    6 minutes of this video and i understand use Effect, something that i didnt understand in one hour lesson. Thank you very much 😊

  • @s.bamahfoodh
    @s.bamahfoodh ปีที่แล้ว +1

    that was really great. I feel like I understand ever slightly more

  • @sambacarlson
    @sambacarlson ปีที่แล้ว +1

    You are a Genius man! 💯👌and you really really know how to explain. Thank you man

  • @cristianouzumaki2455
    @cristianouzumaki2455 4 ปีที่แล้ว +3

    I would like to know from those who disliked like exactly what did you not like. This is one of the best useffect exp out there.

    • @riyadzaigirdar5394
      @riyadzaigirdar5394 4 ปีที่แล้ว

      He didn't explain the why it renders, bacause the state changed..and also print 2 renders so...one for the jsx other for the state change....and he should have also shown an example of setTimeOut in Useeffect

    • @cristianouzumaki2455
      @cristianouzumaki2455 4 ปีที่แล้ว +1

      @@riyadzaigirdar5394 If you are trying to learn a hooks concept it's logical that you know basic react concepts like state change impact and setTimeout is a js concept, why learn react when one is not aware of js concepts.

    • @riyadzaigirdar5394
      @riyadzaigirdar5394 4 ปีที่แล้ว

      Those are morons, dont think of them...they will have more "why's" in life then "yes"

  • @numberoneBORON
    @numberoneBORON 2 ปีที่แล้ว

    You have a gift man, I really understand when I watch your videos!

  • @snovich_117
    @snovich_117 2 ปีที่แล้ว

    close to nine months not understanding useEffect, thans for your help. It was the best one

  • @chandrakant6283
    @chandrakant6283 2 ปีที่แล้ว +1

    Extremely Useful, I've just picked up react and these small doses of lectures are really making the difference.
    Thanx, Kyle.

  • @heyamjoe
    @heyamjoe 2 ปีที่แล้ว

    I always look forward to the intro tune, it's soothing.

  • @awesomejs
    @awesomejs 4 ปีที่แล้ว

    So many times used useEffect but now i understand properly, respect for you sir.

  • @archdetective
    @archdetective 2 ปีที่แล้ว +1

    I had better luck with you than my prof. Thanks a lot!

  • @JosephLKausi
    @JosephLKausi ปีที่แล้ว +1

    Wow thank you, bro, now I have a clear idea on useEffect

  • @frankenfishdom
    @frankenfishdom 10 หลายเดือนก่อน

    thanks for breaking this down so well, I finally understand what's going on!

  • @Aresqn87
    @Aresqn87 3 ปีที่แล้ว

    The best REACT explanation on TH-cam. Thanks.

  • @metinkucuk734
    @metinkucuk734 ปีที่แล้ว +3

    Hello, thank you for your precious efforts you put on every single video. I have a little question (it may sound silly since I'm a beginner): At the beginning of the video why "render" logs to console 2 times? Is it because state is updated twice (one by useState and another by useEffect? Thank you very much in advance for every replies.🎖🏆

    • @eightyeightdays
      @eightyeightdays ปีที่แล้ว +2

      I think it's because in development React uses strict mode and renders components twice. If you create a production build or remove the strict mode tags that wrap the main application things will render as expected.

    • @lukas.webdev
      @lukas.webdev ปีที่แล้ว

      @@eightyeightdays Correct. Great explanation! 😉

  • @GoddessofWarr
    @GoddessofWarr 2 ปีที่แล้ว +1

    So clear... I was struggling with this concept, now it's ok, thank you very muck Kyle !

  • @pranavp4122
    @pranavp4122 2 ปีที่แล้ว

    Thank you Kyle...... Your video is very helpful for the beginners like us!

  • @johnnielondon9840
    @johnnielondon9840 ปีที่แล้ว

    I’ve now watched a couple of your videos for different react hooks and they’re great. Really clear and to the point. Thank you Kyle

  • @rodrigom.castilho4095
    @rodrigom.castilho4095 4 ปีที่แล้ว

    Solved a massive pain in the ass 4 minutes, 6 seconds in. Best subscription I ever made here.

  • @shadmanmartinpiyal4057
    @shadmanmartinpiyal4057 3 ปีที่แล้ว

    wow.. that clean up thing just blew my mind. I have been a react developer for a while now, still didn't know this. Well everyday we learn, we grow.

  • @SohamNag12321
    @SohamNag12321 2 หลายเดือนก่อน

    You are the reason I know React! Thank you!

  • @DeepakSingh-sy4ws
    @DeepakSingh-sy4ws 4 ปีที่แล้ว +1

    i have no words which can appreciate your work.

  • @bigbabyg
    @bigbabyg ปีที่แล้ว

    honestly, along with this dope explanation, i recommend just reading the react docs, they are well explained and easy to digest.

  • @SouradeepBasuTechsavvy
    @SouradeepBasuTechsavvy 4 ปีที่แล้ว +2

    Man you literally are a god to me! I learn more from you than at University!

  • @SitaMbili
    @SitaMbili 3 ปีที่แล้ว +1

    This video makes useEffect so clear and I feel like I finally understand it now thanks to you!

  • @oudom_nohara
    @oudom_nohara ปีที่แล้ว +1

    Concise and Clear!!!

  • @anilpgonade8503
    @anilpgonade8503 ปีที่แล้ว +1

    The best explanation, great job man

  • @michaelNXT1
    @michaelNXT1 2 ปีที่แล้ว

    You're the best, I'm starting to learn React Native and I'm looking forward to have my questions answered by you!

  • @whathappenedthere592
    @whathappenedthere592 ปีที่แล้ว +1

    one of the best explanations ever...loved it

  • @debanjansinha3750
    @debanjansinha3750 3 ปีที่แล้ว

    man u are awesome the way u explain things in a simple manner really helps a lot for the people keep up doing the good stuff..

  • @gmzcj
    @gmzcj 3 ปีที่แล้ว

    He isn't joking when he says his job is to simplified the web. Very easy to follow!

  • @rohitchaudhry4355
    @rohitchaudhry4355 2 ปีที่แล้ว

    Best explnation I have come across for the react hooks !!

  • @Status-i8n
    @Status-i8n ปีที่แล้ว +1

    really good explanation man..u helped a lot thank u so much..

  • @zqgAFf
    @zqgAFf 2 ปีที่แล้ว +2

    Hi Kyle I came here for a refresher ,since React 18, we unmount remount automacally,does it mean we no longer need this cleanup function mentioned in this video ?

  • @AndreasWaatz
    @AndreasWaatz 4 ปีที่แล้ว

    Hello, My problem is that my View with Text renders before my random number generates in function. So nothing gets displayed in Text. What should I use to render random number first the Text?

  • @ryo736
    @ryo736 3 ปีที่แล้ว +6

    Hi, I am a beginner of React and your videos are really helpful for me! Thank you a lot!
    And I wonder if you would be willing to make the automatic captions on? That will be friendlier to the foreign audience like me🙇‍♂️ Thanks for your amazing videos again.

  • @kevinkiumbe5620
    @kevinkiumbe5620 8 หลายเดือนก่อน

    YOU ARE INCREDIBLY TALENTED ! MANY THANKS

  • @vnoommuy
    @vnoommuy 4 ปีที่แล้ว +11

    Hey man, thanks for your amazing work. Have you ever considered streaming?

    • @WebDevSimplified
      @WebDevSimplified  4 ปีที่แล้ว +13

      I've thought about it but really don't have the time to do so right now. I can barely squeeze in the videos I do make each week.

  • @darentok8608
    @darentok8608 2 ปีที่แล้ว

    Thank you for this. Finally understood useEffect and useState

  • @dystopian_1
    @dystopian_1 ปีที่แล้ว +1

    Very nice, brother... Thank you!

  • @anmolsharma433
    @anmolsharma433 4 ปีที่แล้ว

    yo man hats off to you man you can break any complex topic into simple pieces love your vids man.

  • @shaybatman7108
    @shaybatman7108 2 ปีที่แล้ว

    This is the best channel on youtube!

  • @coltgar2465
    @coltgar2465 4 ปีที่แล้ว

    You are my go to channel when I need to learn

  • @sammcalilly107
    @sammcalilly107 2 ปีที่แล้ว

    this helped me learn how i've been improperly using hooks. thanks!

  • @kal1nadam205
    @kal1nadam205 10 หลายเดือนก่อน

    amazing explanation in such a short video, thank you!

  • @mxolisingwenya5486
    @mxolisingwenya5486 2 ปีที่แล้ว

    The best and clear explanation ever

  • @is-sam
    @is-sam 3 ปีที่แล้ว +1

    You are awesome man! You explain things in a very simple and comprehensive manner, thank you :)

  • @rickeyupadhyay6898
    @rickeyupadhyay6898 2 ปีที่แล้ว

    I just love the way you explain Very straight forward!

  • @BinaryGear
    @BinaryGear 7 หลายเดือนก่อน

    Fantastic tutorial as always!

  • @AdamElMou
    @AdamElMou 3 ปีที่แล้ว +1

    I never comment but wow. You're like a gift to the internet, thank u, rlly

  • @woodyboy123
    @woodyboy123 3 ปีที่แล้ว

    You are the best man. So quick and easy to understand when you teach it. Can't believe I've been putting off taking the time to learn hooks when all it would have taken was a 13 minutes with you👍🏼

  • @krishponnaganti1886
    @krishponnaganti1886 3 ปีที่แล้ว

    Thanks dear.. it was nice learning from your tutorial

  • @ЛяманМамедова-ф4х
    @ЛяманМамедова-ф4х ปีที่แล้ว

    Really great explanation! Thank you!

  • @madsidification
    @madsidification ปีที่แล้ว

    Dude you explained is so easily, simply amazing man 🔥

  • @lloyd_jvr9152
    @lloyd_jvr9152 4 ปีที่แล้ว +2

    Amazing video thanx Kyle actually going to start using hook now!

  • @DKMRFCBrlz
    @DKMRFCBrlz 3 ปีที่แล้ว +3

    Hey bro great tutorial, really simple actually haha.
    I felt a little awkward with you looing straight at the camera though LOL, but your hair is amazing, keep it going!

    • @zaeshanvlogs3746
      @zaeshanvlogs3746 3 ปีที่แล้ว

      the dude stares straight into your soul lmaooo, great teacher thoo

  • @yumisunday7088
    @yumisunday7088 2 ปีที่แล้ว

    Great explanation of something i always found very abstract, thanks!

  • @Chewbu
    @Chewbu 3 ปีที่แล้ว +1

    DUDE The school I am with was trying to explain this and I was so LOST! I said screw this and came here and I understood everything by watching it ONCE!!! I spent hours on an assignment scratching my head like what the heck does any of this mean and why is the return the "clean up". NOW I KNOW.

    • @Chewbu
      @Chewbu 3 ปีที่แล้ว

      I am promoting you from now on that $60 deal is seemingly the best deal I have seen in my mfing life. I'll be paying AS SOON AS I'm done with this course I'm in.

  • @Alanm1963
    @Alanm1963 3 ปีที่แล้ว

    Simple clear explanation of the basic concepts. Very helpful. Thank you.

  • @BionicPanda7
    @BionicPanda7 ปีที่แล้ว +1

    Great video man.

  • @MatthewPostrel
    @MatthewPostrel ปีที่แล้ว

    Much better explanation than my Udemy course... Thanks!

  • @bama2619
    @bama2619 6 หลายเดือนก่อน

    Great explanation. Thank you. I am your fan

  • @PankajKumar-ps5gg
    @PankajKumar-ps5gg 2 ปีที่แล้ว

    Best explanation at the end of the video

  • @gabrielaperez42
    @gabrielaperez42 3 ปีที่แล้ว

    This video is incredible, thank you for explain so easier topics that seem impossible to understand!!

  • @yasirupadmasiri3725
    @yasirupadmasiri3725 3 ปีที่แล้ว

    This is most understandable I have ever seen.

  • @Mrinfinity02
    @Mrinfinity02 3 ปีที่แล้ว

    best explanation on internet 👍👍

  • @sikandernaocha2442
    @sikandernaocha2442 3 ปีที่แล้ว

    thnks Bro. u really simplifided coding...