It's easier to write code that makes React's useEffect hook go off the rails than it is to write code that uses it the right way. Let's develop some strategies that you can use to make sure the useEffects you write always work when and how you expect them to work.
Code: github.com/jherr/taming-useef...
👉 I'm a host on the React Round-Up podcast: devchat.tv/podcasts/react-rou...
👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ
👉 Discord server signup: / discord
👉 VS Code theme and font? Night Wolf [black] and Operator Mono
👉 Terminal Theme and font? oh-my-posh with powerlevel10k_rainbow and SpaceMono NF
0:00 Introduction
0:27 Setup
1:38 Creating useFetch
6:42 [ DANGER ZONE ] Depending On Objects
7:30 All About References
13:17 Fixing Our Dependencies
15:16[ DANGER ZONE ] Function Dependencies
19:02 Quick Check-In
19:50 Cleanup Functions
21:25 Depending On State Mutated In The useEffect
24:51 Outroduction
#reactjs #useEffect
This is by far one of the most useful videos I have watched over my 10 years of youtube watching career. seriously. I wathced it twice yesterday, didn't get it. Rewatched today and get everything. Absolutely great video.
Wow, thanks!
Joon I see your 3 watch attempts and raise you two.
@@jherr Thanks for code included!
I just watched this, and this video is trash literally there is no point to call use effect here when you can literally remove useEffect and call them normally.
I thought I'd just about mastered useEffect but this taught me even more. Especially about what react does under the hood. Your videos are a goldmine.
100% agree
I had the exact same thought haha. He explains the concepts so well.
He is expert
Kudos to KZhead algorithm for recommending this gold mine!! Every time I re-watch the same lecture, I learn something new from it. Even the shorts are too useful. Thanks for all your effort mate!!
hands down the best teacher of React. I kid you not !!!
The useCallbackRef pattern is EXACTLY what I was missing in my mental puzzle to properly memoize passed functions. Thanks 🙏
This is one of the best break downs of a hook I have seen, hope to see more like this.
This video literally cleared up a lot of confusions. Really grateful. This video is a gem 💎
very clear and an in depth uses of some of react hooks, thanks Mr. Jack as a usual!
So amazing that you explain all aspects of a feature deep and complete like this
This is easily one of the best code related (at least when it comes to React) videos I have ever watched. I thought I had a pretty good idea about how useEffect worked, but I learned a lot from this and deepened my understanding. I'm sure there are optimisations I can do in my codebase now armed with this knowledge :)
This is the best piece of content on useEffect I have seen so far. It's so clear conceptually and pratically on point. I legit feel more confident using useEffect now, I get it!! Thank you Jack!
Fantastic explanation of a sometimes frustrating hook in React, definitely bookmarking this one!
Thank you so much for this. I've been struggling with this for weeks!
Just discovered your channel now, and I'm very impressed with the lucidity of your explanations!
This is really cool. I once taught I knew all about useEffect, but watching this made me realize I never new nothing. Love how you broke it down. Keep it up
Every react dev should watch this video. You explain concepts so clearly and at such a good pace! All your content is so good man!
That last part, using state as dependence I didn't know that. This video is packed with lot of very important lessons. Thanks buddy. Greetings from Tanzania 🇹🇿
The way you explain these topics is amazing
Jack, just found your channel today. Really great content 🎉 thanks for the crystal clear explanation that are built up like a gradual layering of knowledge and skill. This is how tutorials should be.
Your videos actually helped me a few times at work. Hope you'll keep up uploading
What an awesome explanation of the react useEffect hook. Many thanks!
Jack, this is extremely well done, thank you for this!
Best explanation of useEffect I have ever seen. Thanks so much!
Absolutely best explanation about how useEffect dependencies work! 🔥🔥🔥
really help a lot! This is most deep dive video , I ever seen in coding journey
Awesome jack. Got clear idea of useEffect now. Thanks.
Excellent video, excellent channel. The examples you bring are amazing and the way you explain the content, step by step, is really cool. Hello from Brazil!
Great explanation about useEffect. It is a hook with some complexity. Just last week had an example in a pretty large useEffect to programmatically set some form fields based on other filled in fields. In the useEffect, we needed a value to compare to other fields. But had the problem at first that the value kept triggering the useEffect hook undesirably. When creating a reference to that value, the useEffect hook wouldn't trigger when we used that value inside the hook. Learned a lot ;)
I'm a big fan of all your tutorials about React, you are an excellent teacher! If you're interested I (and the community I'm sure) would appreciate to have a dedicated video on useRef fundamentals, behavior and use cases!
Best indepth and easy to understand explaination. Thanks for sharing.
I am glad that I discovered this channel, thanks a lot Sir for your passion to educate people and making our community better
Incredibly valuable again Jack. Thank you 🙏
Woow blown away but the explanation, use case etc. Keep up the good work!!!
Really helpful Man, I appreciate your videos that has quality content and eloquent explaination of process. Thank you so much.
Amazing! Watching this video is like watching a great movie multiple times, and it just gets exciting and fun every time you watch it! Thank you, Jack!
Amazing video, Jack! You're very knowledgeable and underrated. Keep creating!! 🔥
Thank you for your valuable effort Jack 👏
Your content is amazing as always! Thanks for doing what you do!
Best channel I've found so far!! Thank you so much!!
Best video on useEffect so far
Thank you for such great insights and tricks. Lot of respect and a BIG THANK YOU.
A season mastering for all hooks please! Thank you for this vid! Much appreciatted
Great explained, thank you Jack!
Quality video as always Jack! Now I know I never understood useEffect dependency till I watched this video
Am going to tear all my hair out working with this useEffect .😱
So much value in one video!
Eres un Genio Jack, sigue ilustrándonos. Good job
Thank you Jack! Amazing explanation
Grrrrrreat explanation, as always! Thanks Jack!
Wow this tutorial is awesome. This is a very deep explanation. Worth watching it. 😍
Excellent video as usual, Jack !
this is genuinely one of the best videos I've watched explain a seemingly complex concept. once broken down into the fundamentals, paired with straightforward examples (and gotchas!) - the complexity goes way down. thank you Jack! I was in the middle of a large refactor to reduce our eslint errors and the only one remaining is the useEffect dependancy array ones. this video definitely is going to help me tackle the more complicated ones from that.
Fantastic! Thank you! And, of course, good luck!
This is just what I needed, thanks a ton!
Very informative and well explained video. Thank you so much
This is amazing 🤩🤩 Thanks Jack 🙏🏼
Now we are talking, thanks Jack. loved this. we need some advanced stuff on react :)
Thank you for the video! I'd been having trouble on a project recently, but I realize now what I'd been doing wrong!
I had a bug in my user profile's form, but when I found this I knew the solution was here. I watched it carefuly and found the solution. Great video!
Excellent Video Jack thanks.
You are beyond amazing! Thank you so much for this tutorial!
This content is gold. 💯
I agree! 😉
Always been a fan of your tutorials
Awesome video! finally a video that covers them well.
thanks. very informative video with many useful densely packed topics.
Thought about skipping this video came to know much is yet to explore what a gem thanks jack
okay i must admit that, u r amazing, i hv been coding for almost a year now (not much i know) but built few apps alrdy, but once i saw ur video i knew i'm missing few things and also did some mistakes with these apps, and gotta say also ur teaching is awesome, hope u and ur channel best of luck, ty
Excellent material!
The part of the video between 3:51 and 5:20 explains very well the render and re-render lifecycle. I urge anyone who is still a bit nervous about useEffect to watch and rewatch this section til it sticks. I had to draw a diagram to explain to myself what was happening at each step. Also, if you're using console.log within the useEffect hook, don't forget to make sure that there isn't a React.StrictMode component within the index.js file.
Jack, thank you! That's the absolutely perfect lesson! :)
As always, amazing content
Thank you so much for the video! Very Useful! :)
Loved the video thank you!
Excellent video Jack.
I've seen seasoned developers make the mistakes you've shown in the video. Thanks a million for this! I'm a big fan
damn I have been working as full stack engineer for 7 months now but I swear I have to watch this video three times to fully understand . this is one or if not the most underrated videos on youtube on useEffect . I trully understand how this things work. some people think they understand pass by reference but most developers dont understand these concepts. I will share this video for sure. I spent this weekend to go over his videos on useLayout, useCallback ,useRef and so on. thanks a lot.
Superb tutorial! I wish I found you sooner.
I love how knowledgeable you are in React and state management and how you make complex stuff easy to understand. I wish you had a comprehensive React course. I would have definitely bought it in the blink of an eye.
I have a react and typescript playlist for free which is pretty comprehensive.
@@jherrwhere man I want to buy
Great informative video! I didn't forget to subscribe this time. Thank you!
Gold mine of knowledge thats even for free... ! Highly appreciated sir
This is great. Thank you.
You ARE good story teller!! Thanks ❤️
Great content as always.
Very nice and informative video. Also, encourage people to be not afraid of useEffect. But also promotes critical thinking.
I agree! 😉
Thanks for the great content.
Thank you for this, i learned a lot 💙
Really helpful Jack
Why I didn't know about this channel before? ... I mean you're an awesome instructor!! I enjoyed this video so much and I learned a lot!! Thanks so much for this great content, you just got a new suscriber! 🥳
Amazing video !
You're the man Jack!
at 18:00 you used useLayoutEffect, why? It seems redundant, not performant and adds code complexity for no reason. Any reason for not just doing the following? const savedOnSuccess = useRef(options.onSuccess); savedOnSuccess.current = options.onSuccess;
You are correct, I didn't need to do that.
Nice! Thanks!
It's great explanation, sir :)
Great video!
Best Video to learn about useEffect
simply awesome
Amazing job so many light bulbs went off after watching this turtotial.
Jack, can you please make a video on how to set up VSCode for React development? You are an excellent expert in both!
The title and thumbnail are opposite of click bait. I almost didn't click it thinking I'm gonna get the same basics, aren't I? Boy was I so wrong I am glad that I clicked it.
Thank you sir very helpful
Jack. I love you! That was great and really helpful!