useMemo Explained | React Hooks useMemo Tutorial

  Рет қаралды 29,148

Dave Gray

Dave Gray

Күн бұрын

Пікірлер: 89
@sergiorey2049
@sergiorey2049 2 жыл бұрын
One of the very best videos I have seen about React and JS, I'm sure a lot of developers have come across issues like these not knowing exactly the cause and what to do, I wish I had seen this a year ago lol, great stuff Dave keep it up!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you Sergio! I'm glad you liked it 💯🚀
@TradingBloke
@TradingBloke 7 ай бұрын
you are literally the best javascript teacher on youtube or udemy or online , in few minutes you taught what others teach in 1 hour
@nemanjadjoric8765
@nemanjadjoric8765 2 жыл бұрын
Still can't believe this is a free course !!! Dave, you are an outstanding teacher !!!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you, Nemanja! 🙏
@rajeevranjansingh7103
@rajeevranjansingh7103 2 жыл бұрын
That's really awesome. Anyone can understand the real difference between useMemo and useCallback. Thanks a lot Dave😍😍
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 💯
@devworks8787
@devworks8787 Жыл бұрын
Thank you very much. I had big trouble understanding the useCallback and useMemo hooks even though i have seen endless tutorials. But finally yours helped me understand it! I had big problem understanding if a usecallback should always be used alongside usememo. Now I finally understood
@ifeanyichimbo
@ifeanyichimbo 7 ай бұрын
Thanks so much Dave for your great lessons. Your explanations make it possible for a nub to get it.
@tidyjii7348
@tidyjii7348 Жыл бұрын
you're the best tech teacher in youtube!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you for the kind words!
@MaksymMinenko
@MaksymMinenko 2 жыл бұрын
This is one of the best explanations on what useMemo and useCallback are. You did an excellent job with this video - thanks!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're very welcome! 💯
@jsdragon6500
@jsdragon6500 2 жыл бұрын
This is an important advanced stuff for anyone who develope a largre react app
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Absolutely! 💯
@davidirawan3083
@davidirawan3083 9 ай бұрын
always you are the best for explained some tutorial.Thanks dave
@ahmad-murery
@ahmad-murery 2 жыл бұрын
Really informative video, Things can get tricky if you don't know how React renders components, therefore, it important to choose dependencies carefully and think twice before deploying code to a production server, Thanks Dave,
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome Ahmad. I'm glad to see your comment 🙏
@ahmad-murery
@ahmad-murery 2 жыл бұрын
@@DaveGrayTeachesCode I couldn't resist, with all of my troubles your videos keep challenging me, Have a nice day my friend
@hosseinroosta5154
@hosseinroosta5154 2 жыл бұрын
The best video i could find on this topic. After a few days of searching, finally i could undestand. Thansk a lot mr dave ♥️🙏
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad I could help!
@bsen2267
@bsen2267 Жыл бұрын
Good example Dave, immediately understood the use of UseMemo.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Glad to hear that!
@chunli680
@chunli680 2 жыл бұрын
Thanks for the great content as always! Really like the way you explain things, especially with the examples you gave :D
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! Thank you for the kind words 🙏💯
@lsbernardes
@lsbernardes Жыл бұрын
Thanks for the clear explanation!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Glad it was helpful!
@ArunPrabu007
@ArunPrabu007 2 жыл бұрын
Clear explanation. Able to understand the real usage. Thanks alot
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it was helpful! 💯
@Pareshbpatel
@Pareshbpatel Жыл бұрын
Another great tutorial explaining React concepts, useMemo() in this case. Thanks, Dave {2022-10-19}
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@ivanshoshkov
@ivanshoshkov 2 жыл бұрын
Best tutor ever!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you! 🙏
@zineddinelouzani7069
@zineddinelouzani7069 2 жыл бұрын
Hey form Algeria , you are doing a great work , keepit that way
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you! 🙏💯
@ReactNinja
@ReactNinja Жыл бұрын
Love your tutorials. 😍😍
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@appustudio8637
@appustudio8637 2 жыл бұрын
Piece of gem. Nice explaination.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you Appu!
@h-robs
@h-robs 2 жыл бұрын
Thank you! Such good explanations and examples
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! I'm glad it was helpful!
@rishipaul9613
@rishipaul9613 2 жыл бұрын
I sincerely appreciate your efforts. The second use case of useMemo is explained very clearly without using React.memo(). Thank you very much🙂. I had a doubt when you were explaining that useEffect(( )=>clg('New Number), fib) was not executed again because fib is a primitive type and hence fib is the same during every render of the FC. I thought it was not executed because fib's value is not changing when we enter the value for randomInput. But I have better understanding then before thank you very much again🙂🙂🙂🙂🙂🙂🙂🙂
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 💯
@belkocik
@belkocik 2 жыл бұрын
Thank you for that video! :-)
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@vitaly_p
@vitaly_p Жыл бұрын
Great video!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thanks!
@UnpluggedPerformance
@UnpluggedPerformance 2 жыл бұрын
This is awesome!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad to hear that!
@IshmaelMIRZAEE
@IshmaelMIRZAEE 6 ай бұрын
Thank you so much.
@forstudy7900
@forstudy7900 2 жыл бұрын
Thank you for this amazing tutorial.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're very welcome! 💯
@pratikdevle5830
@pratikdevle5830 2 жыл бұрын
Great video, very easy to understand
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it helped! 🚀
@vladserhiychuk8925
@vladserhiychuk8925 Жыл бұрын
Good stuff. Thanks from Ukraine.)
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Welcome and hello to Ukraine! 👋
@brahimo4701
@brahimo4701 Жыл бұрын
very helpfull thank you so much
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@subhashgn1775
@subhashgn1775 2 жыл бұрын
Great explaination.👌
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you! 💯
@onencanemmanuel4511
@onencanemmanuel4511 2 жыл бұрын
Nice one
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thanks!
@ankushagarwal7378
@ankushagarwal7378 Жыл бұрын
Thanks man I got fullstack developer job because of you, I just can't thank you enough
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Love to hear this kind of feedback! Congrats!!! 💯🚀🙌
@ryan17stehle
@ryan17stehle Жыл бұрын
Is there a reason that the fib function is in the dependency array of useMemo and not useCallback? I can see the computed value "userNumber" being in the dependency array of useMemo, but why is the function there also?
@oortcloud210
@oortcloud210 6 ай бұрын
I wondered this too - I know its inside the function but it seems it is entirely static so why would it need to be regarded as a dependency?
@aya2222
@aya2222 2 жыл бұрын
Great tutorial!! It might be stupid question but I don't get why fib function doesn't need dependency. we don't need to put 'n' in dependency? const fib = useCallback((n) => { return (n
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
useCallback provides a memoized function. It is not calling the function and therefore n is a parameter placeholder and not a value at this point. We apply useCallback to avoid redefining a function on every render. useMemo does call a function. Note the userNumber argument needs to be in the dep. array for useMemo.
@moSaeedNahlous
@moSaeedNahlous 11 ай бұрын
🤩🤩
@hazemsayed633
@hazemsayed633 Жыл бұрын
Do You Know that you are the best & special ?
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@samiullahsheikh5015
@samiullahsheikh5015 2 жыл бұрын
So, if an function is defined in a separate file and is used in a component then there is no need to use useCallback hook. Right? Then what is the practical use case of useCallback?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
This video is about useMemo, but for your questions about useCallback, I have a video here: kzbin.info/www/bejne/fHPCnIKJfdBkeq8
@pauljbarry3
@pauljbarry3 2 жыл бұрын
Hey Dave, great video, I just have one question. When you move fib from outside the component to in the component, why do you have to add fib to the dependencies of the useMemo call? That function is in scope for the function passed to useMemo and fib is never going to change, so can you leave it out of the dependencies of the useMemo call?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Good question, Paul! When defined inside the functional component, the function will always be created again. It looks the same to us, but it will not have the same memory reference. I'm referring to what is called referential equality. This applies to objects, arrays, and functions. Therefore, we memoize the function with useCallback. Now it should have referential equality, but it is still a dependency of useMemo when we create the fib number. You will get a warning/complaint in your console from React if you do not add it to the dependency array. Of course, you could ignore that or put in a comment to disable the eslint for the next line.
@khamzatilek9078
@khamzatilek9078 2 жыл бұрын
tnx sir
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@erictr5582
@erictr5582 Жыл бұрын
Hi Dave, do you run online courses on Udemy?
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
No, but I do hope to release my own premium content in the future. I don't think I will use Udemy to release it though.
@winterheat
@winterheat Жыл бұрын
in the '80s, when people wrote BASIC, they had this GOTO statement and people call it spaghetti code, and they got rid of it forever, saying NEVER do that. We are now entering a new era where we need to "memo" a function, and figure out "the dependencies", wow, that's spectacular programming, even more great than "spaghetti"
@Yusuf-ok5rk
@Yusuf-ok5rk 2 жыл бұрын
nice introduction lol
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
If you're not careful, your React apps can suffer from performance issues when you have a function that takes a moment or two to complete processing. By applying the useMemo React hook, you can avoid this kind of processing bottleneck. Just starting with React? I recommend my full 9 hour React course tutorial video here: kzbin.info/www/bejne/iIepcqx8jLRnndE
@KILLCHRISU
@KILLCHRISU Жыл бұрын
subbing because your teaching style is lovely. thank you for your great work Dave!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Welcome aboard!
@keshavjha2641
@keshavjha2641 Жыл бұрын
You are a legend 🙏🙏
@mostafahusany1747
@mostafahusany1747 2 жыл бұрын
Thank you very much Mr.Dave
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You are very welcome, Mostafa!
@mohammadmahdialvansaz8001
@mohammadmahdialvansaz8001 Жыл бұрын
Thanks
BUILD a React Timer with useRef | React Hooks useRef Tutorial
14:03
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,6 МЛН
Bike Vs Tricycle Fast Challenge
00:43
Russo
Рет қаралды 95 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 63 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 69 МЛН
Mastering React Memo
26:56
Jack Herrington
Рет қаралды 135 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 383 М.
What is React.memo - It's not useMemo
15:29
Dave Gray
Рет қаралды 9 М.
Avoid this React State Mistake | React Previous State Explained
13:23
All useEffect Mistakes Every Junior React Developer Makes
22:23
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 101 М.
Learn React useReducer Hook with Examples
14:19
Lama Dev
Рет қаралды 176 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,6 МЛН