Learn useEffect In 13 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ค. 2020
  • 🚨 IMPORTANT:
    Full React Course: courses.webdevsimplified.com/...
    1 Year Free Hosting: www.atlantic.net/webdevsimpli...
    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.webdevsimplified.com/202...
    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.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    #ReactJs #WDS #useEffect

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

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

    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 ปีที่แล้ว +9

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

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

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

    • @vapeurdepisse
      @vapeurdepisse ปีที่แล้ว +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 ปีที่แล้ว +1

      @@prince5922 no

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

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

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

    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 3 ปีที่แล้ว +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 ปีที่แล้ว +379

    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. 😅

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

    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 9 หลายเดือนก่อน +1

      Yes, I agree 100%! 😉

    • @loneWolff1995
      @loneWolff1995 3 หลายเดือนก่อน +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 !!!!*

  • @user-hs2so8zo9m
    @user-hs2so8zo9m 6 หลายเดือนก่อน +10

    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.

  • @learningdevelopment7429
    @learningdevelopment7429 3 ปีที่แล้ว +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!!

  • @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👍🏼

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

    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

  • @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.

  • @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 5 หลายเดือนก่อน

      What do you do now just curious 🧐

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

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

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

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

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

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

  • @riturathinsharma5931
    @riturathinsharma5931 3 ปีที่แล้ว +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 :)

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

    Kyle is the best ,he explains so much things in a very time span.Other channels sometimes confuses me with so much mess.

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

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

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

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

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

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

  • @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!

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

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

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

    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

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

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

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

    Thank you so much!!The examples were quite easy to understand.I got it so well.I wish you the best!

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

    Thank you man. Keep making these types of videos. I love them all. Very cool precise and clear. No b.s.

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

    You tone is so smooth I can understand you code without looking at screen.
    Thanks for such great videos

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

    As always: simple and clear explanation! Thanks!

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

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

  • @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..

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

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

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

    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.

  • @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!

  • @IMChristianLowe
    @IMChristianLowe 2 ปีที่แล้ว +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 2 ปีที่แล้ว +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)....

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

    Wow, super easy to follow along, thank you for sharing this with us :)
    Subscribed!

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

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

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

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

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

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

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

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

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

    you're a life saver and amazing teacher

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

    The best REACT explanation on TH-cam. Thanks.

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

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

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

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

  • @non-stereotypicalprogramme3666
    @non-stereotypicalprogramme3666 3 ปีที่แล้ว

    Thanks for this video. Fast, simply and well explained

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

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

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

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

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

    You definitely have the teacher mindset. Really clear!

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

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

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

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

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

    very good tutorial! I understood this sentence and i hope that I will make bigger progress! Thank you!

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

    Dude you explained is so easily, simply amazing man 🔥

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

    Excellent examples, very clear explanations, thanks!

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

    You have the perfect articulation. Great stuff, thanks.

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

    I just love the way you explain Very straight forward!

  • @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.

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

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

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

    very much comprehensive and intuitive video, Great work thank you :)

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

    Your channel is a game changer. Thanks Kyel!

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

    Your videos are very easy to understand. Thanks for the content.

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

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

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

    Simple and no clutter, great one.

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

    Auto subscribe, awesome explanation it's easy to understand. Thanks bro keep the good work

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

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

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

    Great explanation as always, Thank you very much!

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

    amazing explanation in such a short video, thank you!

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

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

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

    Thanks man, you save me reading about side effects in the docs haha :). Cheers.

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

    Love your videos. Explanations are clear

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

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

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

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

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

    Your videos are too great, I have no words to thank enough.👍👍🙌🙌

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

    Thank you. I fully understand React hooks in really really 13 mins.

  • @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.

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

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

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

    This was a great explanation! Thank you!

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

    i have no words which can appreciate your work.

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

    Best explanation, found exact answers about how does effect actually work

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

    This is the most understandable explanation I’ve ever seen

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

    Thank you! Such a great tutorial!!

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

    Thanks Kyle, Amazing tutorial

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

    Incredible help, thanks Kyle!

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

    nice video! great examples and illustration!

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

    Fantastic video... thank you for the trenchant explanations!

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

    Very simple explanation, thanks!

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

    Thank you for this. Finally understood useEffect and useState

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

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

  • @niloben659
    @niloben659 10 หลายเดือนก่อน +1

    Once again knocking it out of the ballpark

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

    Thanks, you made this easier for me to understand

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

    Hey Kyle , best explanation with practical examples . Can you please also make videos on redux saga and redux thunk?

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

    Awesome explanation. You made my task easy

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

    That was so helpful! Highly appreciated buddy :)

  • @user-wm7el6sq2j
    @user-wm7el6sq2j 9 หลายเดือนก่อน

    Really great explanation! Thank you!

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

    Great rundown. Thank you man.

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

    Thank you Kyle so clear explanations.

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

    great video. great explanation. thanks WDS!

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

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

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

      Learn from the enlightened

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

    so good bro, I recently learned react and i wasn't totally clear about useEffect.

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

    Great video Kyle, cleanup function became as clear as the day. One thing I wanted to ask you, is when you unmount the component is adeventListener still stays attached and then when when you mounted it back gets removed by cleanup function, or is it gets removed before you unmount the component? Thanks Kyle, love your tutorials man👍👍👍

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

    thnx Kyle
    you are trully gifted
    amazing explenation, helped me a lot

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

    bro you are the best in explaining things!!!

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

    These videos are really helpful. Hats off to you boss. :D