Mastering React Memo

2024 ж. 19 Сәу.
130 227 Рет қаралды

React.memo, useMemo, useCallback, should you use them? When should you use them? Lets improve your React coding skills right now!
👉 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:44 Project Setup
4:22 Using React.Memo
6:35 Traditional Memoization
8:49 How React Memoizes
11:57 When You Should Memoize
14:11 Renaming React.Memo
14:24 Should You Use React.Memo?
14:49 Don't Sweat Re-Renders Too Much
17:51 useMemo
21:02 useMemo Examples
23:43 useCallback
25:40 5 Things To Remember
26:38 Outroduction
#react #useMemo #useCallback #react.memo

Пікірлер
  • Jack, I think you should use "reference identity" instead of "referential integrity". The "referential integrity" is a term from a relational database theory and it is a guarantee that all references (foreign keys) point to existing entities and there are no "dangling" references/pointers in your database (or application state). For example, in a normalized Redux store it would mean that if a post object in a "posts" collection has a list of IDs of "comments" (a foreign key form "posts" to "comments"), then all comments referred by the post must be present in the "comments" collection in the store. In a normalized store posts do not keep direct references to comments, only IDs, so it becomes important to care about the referential integrity, as it does not happen naturally. The "reference identity" OTOH is just a special case of an equivalence relation, which guarantees equality of two referenced objects if and only if the references point to the same object ("shallow equality") but ignores structural equivalence ("deep equality"). React relies on the reference identity AKA "shallow equality" of two objects. It does not care about referential integrity, like lack of dangling references in your application state.

    @onebronx@onebronx2 жыл бұрын
    • Fair enough. I'll do that in videos that folow.

      @jherr@jherr2 жыл бұрын
    • How did you manage to write such a big comment?

      @sahej97@sahej972 жыл бұрын
    • @@sahej97 using a PC instead of a phone :)

      @onebronx@onebronx2 жыл бұрын
    • @@sahej97, this means he knows these things and followed the video to the end, which implies that, Jack is real good. Keep it up guys, we're luck to have people like you

      @raymondmichael4987@raymondmichael49872 жыл бұрын
    • @@jherr, I watched the whole video. I'm waiting for the next video. Thanks for helping us out

      @raymondmichael4987@raymondmichael49872 жыл бұрын
  • that transition at 0:45 is NICE.

    @thehaptiK@thehaptiK2 жыл бұрын
  • Thank you again! So clear explanation! That is the main difference between junior and senior-level developers - it`s when you can provide a clear explanation to your "team members".

    @alexanderkuznetsov634@alexanderkuznetsov6342 жыл бұрын
  • These videos are gold Jack, it's hard to find such high quality and down to earth tutorials like these. Keep it up!

    @nicholasfane1081@nicholasfane10812 жыл бұрын
  • Great content Jack, thank you for taking the time to explaining React Memo so clearly.

    @bythealphabet@bythealphabet2 жыл бұрын
  • Recently discovered your channel and have found it extremely valuable! Liked and subscribed. You have a very clear way of explaining things that I have been struggling with for quite a while :D Thanks and hope your motivation stays high for creating more content!

    @Gringo0517@Gringo05172 жыл бұрын
  • Your explanation skills and demo demonstrations are so amazing! Great videos!

    @adnanahmed4176@adnanahmed4176 Жыл бұрын
  • Been looking at lots of videos and reading a lots of articles but couldn't get my head around when and on what these hooks must be used. And with this video everything is crystal clear. Was such a simple concept. Thanks Jack for this great video. Been following your a while for quality content.

    @mirajaryal3322@mirajaryal33222 жыл бұрын
  • Amazing content as always , really can tell that this vids are professional because of how fluent you are with the syntax , the examples and the visuals of the video overall everything is very pleasing thank you

    @alimohammadi1517@alimohammadi15172 жыл бұрын
  • I have seen dozens or even hundreds of youtube tutorials and this one is one of the best. Great content. I like most that the information is coherent, forming a whole. It is explained in detail. The pace and tone of Jack's voice are engaging. Fantastic job 👏👏👏

    @leszekmodrzejewski7372@leszekmodrzejewski7372 Жыл бұрын
  • These Mastering React Hooks series are really, but really helpful. I can't thank you enough for everything I'm learning from this. Keep it going!

    @dastansito@dastansito2 жыл бұрын
  • This is something really important that almost anybody takes the time to explain. Thank you so much and keep on this kind of amazing vids!

    @juandsoto1651@juandsoto16512 жыл бұрын
  • Really great explanation. Your videos are getting better and better! Thanks a lot!

    @DavidCCR@DavidCCR2 жыл бұрын
  • Your videos are always so clear, detailed and to the point. Every time I click on one of your videos and think I know about the subject, I always end up learning something new. Thank you for sharing your knowledge with us!

    @geralt36@geralt36 Жыл бұрын
  • Thank you Jack ! I was looking forward to this. I am going to do few experiments for my own cases, but after that video, I feel better and less stressful about re-rendering I guess 😊

    @EnesKab@EnesKab2 жыл бұрын
  • This is really on a whole another class. Rich information yet so compact at a time. Thank you!!

    @permanar_@permanar_ Жыл бұрын
  • Very helpful video. Straight to the point, examples and comparisons included. Definitely cleared up a lot of my questions about React memoization. Thank you 🙏🏻

    @me_rinta@me_rinta Жыл бұрын
  • Hi Jack, Extremely grateful for this insightful Mastering React series, a small correction at 18:30, I assume you meant to click on the Re-Render app button instead of the Change color button to demonstrate the memo failure with object type parameters.

    @swapnilsingh7553@swapnilsingh7553 Жыл бұрын
  • This is the best video I have seen on the topic. From giving the concepts to telling its pros cons with correct usage. All things are included in depth summarized in this 27 min tutorial. Hope you channel grows

    @mohsinwaseem9770@mohsinwaseem9770 Жыл бұрын
  • Thank you! I really enjoy your content. Always concise and insightful! Great editing btw :)

    @lsowein@lsowein2 жыл бұрын
  • I watched a lot of other docs and tutorials on those hooks and now finally I feel understand this properly, even if I used it many times already successfully now I get the fine details and differences and also when not to use them

    @retinafunk@retinafunk2 жыл бұрын
  • Fantastic explanation! Personally, I was struggling and confused about using memorization in React, but this video definitely helped me to understand this topic. Thanks Jack ❤

    @Will4_U@Will4_U2 жыл бұрын
  • Excellent breakdown, I think the part on renaming the function in your head is critical to understand this function for what it actually does. Really well edited video too, I'm looking forward to more from your channel!

    @mattlennon3@mattlennon32 жыл бұрын
  • The way explianed memoization comparing to traditional memorization was just amazing. in fact you just thought me how memizationreally works under the hood in react. the part where you mentioned when to or not to use moemo in react was also great example to understand the need for memo. thank you very much🙂

    @arsalanhussain6499@arsalanhussain6499 Жыл бұрын
  • From the moment you casually typed “zoom” as a css property (which I didn’t realise was even a thing), I knew this was going to be a good’un. Thank you, Jack. Wonderfully clear explanations. 🙏😎

    @sideshowlol@sideshowlol2 жыл бұрын
  • The best and most thorough explanation I've ever seen! Fantastic!👍

    @xieweiling7543@xieweiling75432 жыл бұрын
  • The explanation about VDOM and DOM was amazing, I didn't know any of how that worked in React and I bet a lot of people don't as well. Thank you for your videos!

    @vitorwindberg4212@vitorwindberg42122 жыл бұрын
  • Great video, Jack! Thank you so much for your work! Keep it going.

    @artyomkorbut5623@artyomkorbut56232 жыл бұрын
  • Goddamn! Mm-mm-mm! You took them tutorials on the next level with these transitions and the chapter titles! Probably the best React/Typescript youtube channel out there. Thank you so much for the hard work, can't wait to see you have 500k+ subs on your channel.

    @rism8345@rism8345 Жыл бұрын
  • Hey Jack, just wanted to drop a quick message to say thanks for the video! I've been following your content for quite a while now, and I gotta say, you're hands down the best I've come across. I've learned so much from you, not just about coding but also your logical and concise explanations. Thanks again, really appreciate it!

    @sergemorales8709@sergemorales87098 ай бұрын
  • Thank you for this. I've been watching several videos from you, and they are all great. You go deep and into details, and throughout the way you teach a lot of small things that can help build the bigger picture. I'm interested to know about your career history, can you make a video about that? like when you started to program, what languages, frameworks, talk about the evolution of computer science from your aspect and so on... Cheers! (btw finally subscribed!)

    @djitaispector2329@djitaispector23292 жыл бұрын
  • The best tutorial on YT I've ever watched about the topic!

    @alii4334@alii4334 Жыл бұрын
  • Jack one of the best breakdowns I've seen on React Memo thank you very much!

    @boopfer387@boopfer387 Жыл бұрын
  • One of the best channels out there! Thank you

    @MistaT44@MistaT442 жыл бұрын
  • Loved your explanation. I subscribed immediately!!

    @sourabhkulkarni1731@sourabhkulkarni1731 Жыл бұрын
  • By farrrrrrrrrrrrrrrrrrrrrrrrrr the best tutorial on those topic out there. Greate explanation! 👏

    @andenetalexander5244@andenetalexander52442 жыл бұрын
  • Great explanation Jack! Thank you for your content!!

    @kyriakosbekas@kyriakosbekas11 ай бұрын
  • Thank you for your amazing explanation! You made it so much clear to understand!

    @alisonhj@alisonhj Жыл бұрын
  • I love the way you jump to code instead of wasting time on talking like others. Keep it up!

    @vigyanhoon@vigyanhoon Жыл бұрын
  • Thank you Jack! :) Every time I come to you channel I learn something new :)

    @maxklammer3370@maxklammer33702 жыл бұрын
  • Found exactly what I've been looking for. Great explanation. Clear and easy to understand. Please do a series on advance react concepts

    @minsaf8216@minsaf82162 жыл бұрын
    • So what would you consider advance React concepts?

      @jherr@jherr2 жыл бұрын
    • @@jherr concept like Error boundaries, custom hooks

      @minsaf8216@minsaf82162 жыл бұрын
    • @@minsaf8216 Cool. I actually have covered those a bunch, just not in their own videos. I'll have to think of a good way to do that specifically for its own video.

      @jherr@jherr2 жыл бұрын
  • I had about a week of building an app using some components I didnt understand that seemed to require useCallback. I kept getting stale state from it. Now I understand why! Thank you much!!!!

    @mcfliermeyer@mcfliermeyer Жыл бұрын
  • wow the content is getting so much better ! great video !

    @axe-z8316@axe-z83162 жыл бұрын
  • Great Video. Thanks soo much. The whole react memo became very clear for me.

    @mdnamussakib8077@mdnamussakib8077 Жыл бұрын
  • Thanks for the video! Comprehensive, straight forward and thorough. 🙏

    @lucaszapico926@lucaszapico926 Жыл бұрын
  • The best and detailed explanation on memo. Thank you so much.

    @sukeshkumard6064@sukeshkumard60642 жыл бұрын
  • Wow. These kind of videos i need learning react. I'm getting tired about all the crash courses(these are good for getting to know react)or full stack whatever and everybody talks about all the basics for begginers. Your videos are taking my understanding about react to a new level. Thank you. I hope you cover more and more advanced stuff because you explain them so well. Like a teacher.

    @vladandreit@vladandreit2 жыл бұрын
    • Check the channel, I think you'll find there are enough advanced topics videos to keep your happy for a while. :)

      @jherr@jherr2 жыл бұрын
  • Thank you, your explanation way is so amazing and I learned a lot and how you use examples is great.

    @akramadil7502@akramadil75022 жыл бұрын
  • This was purely informative, thank you so much.

    @batumanav@batumanav Жыл бұрын
  • Great content. You're a wonderful teacher. Keep up the good work, Sir.

    @brilliantatosam6882@brilliantatosam6882 Жыл бұрын
  • Great stuff ! This topic was always confusing to me. Thanks !

    @ukaszzbrozek6470@ukaszzbrozek6470 Жыл бұрын
  • Thanks! Really nice and informative video, and again thanks for taking my suggestion :)

    @krishgarg2806@krishgarg28062 жыл бұрын
    • It was a good one!

      @jherr@jherr2 жыл бұрын
  • Thanks for this, my useMemo and virtual dom concept wasnt much clear before I watched this. Thanks.

    @vigyanhoon@vigyanhoon Жыл бұрын
  • Thanks so much....this is a great video. I learnt alot 💯😍

    @SkillerChampion@SkillerChampion Жыл бұрын
  • Extremely good explanations, thank you!

    @JulioDx3480@JulioDx34802 жыл бұрын
  • Thanks mate, perfect explanation!

    @dazjacktar6202@dazjacktar6202 Жыл бұрын
  • Jack you are an amazing teacher! Thank you for this video!

    @444ous@444ous2 жыл бұрын
  • Excellent video as always ❤️

    @talhaibnemahmud@talhaibnemahmud Жыл бұрын
  • awsome and comprehensive explanation thanks a lot

    @hamdinahdi899@hamdinahdi899 Жыл бұрын
  • Hey Jack! I really appreciate the deep dives. Thank you!

    @anncascarano8589@anncascarano85892 жыл бұрын
  • Hey, thank you for this awesome video! Really good explanation :)

    @cayque_freitas@cayque_freitas2 жыл бұрын
  • Great great video!! U explained the useMemo so well !!!

    @user-oy4kf5wr8l@user-oy4kf5wr8l2 жыл бұрын
  • This is GOLD ! Thank you.

    @thebattinson1278@thebattinson12782 жыл бұрын
  • Hey! Jack, Thanks for explaining the memoization. This explanation really cleared the concept and usage well. Can you also create a video on redux-thunk vs redux-saga. That would be real great. Thanks again

    @b29gupta@b29gupta Жыл бұрын
  • Thank you for the masterclass on these topics

    @oliver_ai@oliver_ai2 жыл бұрын
  • I watched several videos on this channel, and I see all new videos ; To my surprise, I wasn't a subscriber to the channel yet!! 🙆🏾‍♂️, Subed now 🤓

    @raymondmichael4987@raymondmichael49872 жыл бұрын
  • i liked the video before even watching.. I know it will be a great one 💯

    @mirtanvirahmed3868@mirtanvirahmed38682 жыл бұрын
  • You can tell right away by his thinking out loud, that he is a senior developer xD. Thank you for your amazing content :)

    @utkarshsrivastava4106@utkarshsrivastava4106 Жыл бұрын
  • Thanks, this was the best explanation I've ever heard.

    @rafaelnunes6918@rafaelnunes6918 Жыл бұрын
  • Best explanation for memoization on KZhead.

    @atuldubey8146@atuldubey8146 Жыл бұрын
  • best explanations ever I love your way for teaching.

    @diyaagubarah3328@diyaagubarah3328 Жыл бұрын
  • best explanation with example. Thankyou

    @someshmusunuri4233@someshmusunuri4233 Жыл бұрын
  • you've got a new subscriber sr, you have the craft or art of teach good and clear

    @haroldpepete@haroldpepete2 жыл бұрын
  • "React Memo" == "Render if the props have changed"

    @down__lo7359@down__lo7359 Жыл бұрын
  • Thanks, what an incredible explanation ❤

    @muhammadarsalanahmed5643@muhammadarsalanahmed564311 ай бұрын
  • Great content Jack, thank you!.

    @cuongduong257@cuongduong2572 жыл бұрын
  • best video on this subject thanks for helping me understand this better

    @andreslikesramen@andreslikesramen2 жыл бұрын
  • Another great video! Thanks!

    @trenthm@trenthm Жыл бұрын
  • Great explanation! Was referring the official react doc but it wasn't as clear as this video!

    @jarrettyew@jarrettyew2 жыл бұрын
  • @26:36 my face when he slid across the room revealing that the background is a green screen :o :o :o Thats the most impressive green screen I have seen on youtube, it looks so realistic! Also, the transition between your hair and the background is pretty much not noticable. Much impress.

    @bjrnolavgjrven2955@bjrnolavgjrven2955 Жыл бұрын
  • Thank you, Jack. I learned a lot 😊

    @user-un9cs7zq5w@user-un9cs7zq5w2 жыл бұрын
  • Thank you so much, Mr. Herrington. It is really informative and well explained.

    @esmaeilmirzaee@esmaeilmirzaee2 жыл бұрын
    • It's Herrington. :) And, thank you.

      @jherr@jherr2 жыл бұрын
    • @@jherr Sorry, my bad. I corrected it.

      @esmaeilmirzaee@esmaeilmirzaee2 жыл бұрын
  • Jack, i have avoided using memoization in React for a long time. I've read blogs, watched tuts, without success. You're lesson here has just made everything click! Your preparation and relevant information are extremely valuable. Thank you very much.

    @rjcrummy@rjcrummy2 жыл бұрын
    • You should still avoid it tho. No reason to use it unless you have a genuine performance issue.

      @jherr@jherr2 жыл бұрын
  • This was such a clear explaination!

    @jijieats@jijieats6 ай бұрын
  • Always great videos

    @Chrosam@Chrosam2 жыл бұрын
  • 8:51 ""it compares the previous props with new props. And when those props have changed it re-renders. Thats all memorization is. "". Missed that in an interview :')

    @tazimmahta7625@tazimmahta7625 Жыл бұрын
  • Awesome, subscribed!

    @designdeveloprepeat651@designdeveloprepeat6512 жыл бұрын
  • Thank you clear explanation

    @abdelrahmanmagdy8946@abdelrahmanmagdy89462 жыл бұрын
  • Great stuff Jack!

    @philipkearney3795@philipkearney37952 жыл бұрын
  • Jack, awesome videos like always, and great detailed explanation. One thing, just before your "5 Things To Remember" section, your video background tilts and slides away - At that moment I looked away and from the corner of my eye it looked like my screen was falling off my desk! Hahahaha, I got a fright there for a split second! 🤣

    @marcelsdev@marcelsdev2 жыл бұрын
    • Hahah, I'll put a warning on the net one. :P

      @jherr@jherr2 жыл бұрын
  • Thank you, this is really impressive and clear.

    @ishan101@ishan1012 жыл бұрын
  • Great video. Subscribed!

    @vikram87in@vikram87in Жыл бұрын
  • very detailed and clear explanation 👍

    @3ggr@3ggr Жыл бұрын
  • Superb, thank you!

    @someone9493@someone94932 жыл бұрын
  • Thanks Jack, for the awesome video

    @shubhamlatiyan7972@shubhamlatiyan79722 жыл бұрын
  • That was something I was looking for!

    @SHIVAMPANDEYSJTG@SHIVAMPANDEYSJTG2 жыл бұрын
  • It was really great explanation, Thanks a lot.

    @davitbokuchava6767@davitbokuchava6767 Жыл бұрын
  • Jack is hands down the best JavaScript teacher on KZhead!

    @Justjames283@Justjames2832 жыл бұрын
  • Clear explanation, now I get it, thank you.

    @julianfmartinez@julianfmartinez Жыл бұрын
  • Jack's discussion of "Don't Sweat Re-Renders Too Much", was eye opening. Thanks for explaining it in reference to old jQuery methods!

    @ajstimson@ajstimson Жыл бұрын
KZhead