React Hooks Tutorial - 27 - useMemo Hook

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • 📘 Courses - learn.codevolu...
    💖 Support UPI - support.codevo...
    💖 Support PayPal - www.paypal.me/...
    💾 Github - github.com/gop...
    📱 Follow Codevolution
    + Twitter - / codevolutionweb
    + Facebook - / codevolutionweb
    📫 Business - codevolution.business@gmail.com
    useMemo Hook in React

Комментарии • 113

  • @MrVisheshsingh
    @MrVisheshsingh 4 года назад +125

    😍
    useCallback: Caches the provided function instance
    useMemo: Invokes the provided function & caches the result

    • @bhupeshbhatt4334
      @bhupeshbhatt4334 4 года назад +4

      what do cache mean?

    • @jackshephard7920
      @jackshephard7920 4 года назад +11

      @@bhupeshbhatt4334 it means store the object(function instance or the result) in memory, so you don't have to recreate it every time

    • @ganesha3559
      @ganesha3559 3 года назад +21

      ​@@bhupeshbhatt4334 In alternate words, assume you have a GK book :)
      Now say you are asked a GK question to which you dont know the answer but you are free to look in the Book. Assume you found the answer.
      Now you are asked that question again. This time you will not look into the Book because you know the answer :p Now you will answer instantly. The ability to remember the question, answer in your mind is CACHING

    • @sindhuMilkyway
      @sindhuMilkyway 3 года назад +2

      @@bhupeshbhatt4334 Pls learn web basics and then come to frameworks/library.

    • @Nikhilkumar-yh7yc
      @Nikhilkumar-yh7yc 3 года назад +20

      @@sindhuMilkyway person used to understand the things when they started implementing the things. He doesn't know he had to study his cache first when he comes to understand he got to know .. so you can't tell anyone this who is eager to learn .. You guys know nothing and doing showoff..

  • @arios0312
    @arios0312 5 лет назад +48

    You are one of the best online teachers. Thanks a lot for your contributions

  • @yuudaemones2624
    @yuudaemones2624 3 года назад +4

    Finally, a simple explanation that goes beyond just reading and demonstrating what is already in the docs. Thanks!

  • @karthickramachandran4701
    @karthickramachandran4701 5 лет назад +42

    Great explanation to be honest .. if you have time to work on a project please build a project with a backend and hooks..

  • @conaxliu9677
    @conaxliu9677 4 года назад +63

    I am starting to feel that some hooks are introduced as workarounds to problems that shouldn't have existed in the first place. It would be great if the React team can come up with solutions that fixes the internal code to avoid performance issues instead of using hooks to wrap around stuff.

    • @thehaystacker7965
      @thehaystacker7965 3 года назад +2

      That is not possible. right? Since each API's in react has its own purpose, developers have to use the additionally provided API's by the framework to work according to their needs.

    • @mwaqze
      @mwaqze 2 года назад

      I totally agree with you.

    • @sabbirsheikhss
      @sabbirsheikhss 8 месяцев назад

      You are right In other programming language we focus on how to update the ui,here we are focusing on how not to rerender

  • @jackwhite5070
    @jackwhite5070 4 года назад +3

    Fascinating description especially the difference between useMemo and useCallback, thank you!

  • @mandihaase2744
    @mandihaase2744 3 года назад +5

    Amazing explanation!! I am finally starting to understand concepts that have been eluding me for some time. Your tutorials are AWESOME!!!

  • @ozzyfromspace
    @ozzyfromspace 3 года назад +1

    Yeah, this is probably the best explanation of useMemo on the internet. Bravissimo, sir!

  • @adityabhosale4446
    @adityabhosale4446 Месяц назад

    i think your the best youtuber for developers, the way you explained and all with sweet voice with better understanding. Should you start react project playlist so we can do better understanding. lots of love from india

  • @SpinningPsycho
    @SpinningPsycho Год назад

    The comment in the last 20 seconds of the video gets my sub! Amazing coverage of this topic!

  • @digvijayyamagekar4300
    @digvijayyamagekar4300 Год назад

    easiest and shorted explanation on whole youtube, thanks

  • @xiaotingshao3689
    @xiaotingshao3689 Год назад

    I think finally I am clear with useMemo and useCallback, but definitely optimization is advance skills in react. I am glad to achieve it

  • @rajadastidar3765
    @rajadastidar3765 3 года назад +2

    Man you have a very conceptual knowledge.

  • @bouyahyabilel2437
    @bouyahyabilel2437 3 года назад +6

    So we have 4 différences way to optimize our code :
    -extends from Pure.Components in the case of using class Components
    -React.memo(class/function Compnent)
    -useCallback(arrow Function , [Denpendecies variables looks for])
    -useMemo(arrow Function , [Denpendecies variables looks for])

  • @bhaktisagarwithankit
    @bhaktisagarwithankit 3 года назад +1

    Your every example is awesome, clear

  • @RichardAK
    @RichardAK 10 месяцев назад

    why don't more tutors explain like this???? you sir are a hero

  • @sabbasachisaha
    @sabbasachisaha 4 года назад

    Your explanation of each vedio is self sufficient. It's help me a lot to understand clearly. Thanks for creating this.

  • @wallurisatya6986
    @wallurisatya6986 3 года назад

    const incrementAge = useCallback(() => setAge((age) => age + 1), []);
    const incrementSalary = useCallback(() => setSalary(salary + 1000), [salary]);
    This also works based on the knowledge from your earlier tutorials.

  • @fazliddinfayziev-qg1vg
    @fazliddinfayziev-qg1vg 10 месяцев назад

    Thank you brother, It is so great. You explain everything very slowly and amazingly. Awesome bro.
    Keep it Please. 😁

  • @himanshushekhar3694
    @himanshushekhar3694 3 года назад +1

    Wow... This video is simply amazing and cleared lot of my doubts

  • @AtulSharma-mo4od
    @AtulSharma-mo4od 2 года назад

    Simply the best explanation on hooks
    Loved your video
    Way to go brother...

  • @shshawon39
    @shshawon39 4 года назад +1

    Your Teaching style is awesome!

  • @ichigoplayss376
    @ichigoplayss376 2 года назад

    Thanks a lot Sir you explained it way better that I can understand easily...

  • @VinayK22
    @VinayK22 4 года назад +1

    absolutely nailing the tutorials, best on youtube

  • @samiRediAmaniTekeshAlazar
    @samiRediAmaniTekeshAlazar 2 года назад

    thank you as always , simple and straight forward

  • @VitraagShramanSanskriti
    @VitraagShramanSanskriti 2 года назад

    Best and easy to capture explanation

  • @sangitakumre3294
    @sangitakumre3294 4 года назад

    Really... you explain very well...I love your all tutorials...

  • @sanatanShishya1521
    @sanatanShishya1521 6 месяцев назад

    Nice tutorial for performance point of view .
    But if you explain this with console, then it will be much better to understand the rendering of component based on call through useMemo() and without useMemo().
    btw, always thanks for your hard work.

  • @shinaspk9276
    @shinaspk9276 3 месяца назад

    great explanation

  • @sribalaji7321
    @sribalaji7321 2 года назад +1

    Best tutorial 🔥

  • @shivashankar6043
    @shivashankar6043 3 года назад +5

    could we use the useeffect adding dependecies to achieve same like what usememo does?

    • @kunalbabbar7399
      @kunalbabbar7399 3 года назад +2

      Nope you can't collect the return value in useEffect hook as it does'nt return any value it just call the function when dependency changed

  • @mddulalmiah8012
    @mddulalmiah8012 Год назад

    Thank you for your nice presentation. I understand this topic. :)

  • @shubhrajit2117
    @shubhrajit2117 2 месяца назад

    tysm 💖

  • @allensparks6512
    @allensparks6512 2 года назад

    Amazing. You are the best!

  • @enucar
    @enucar 3 года назад +1

    We could just use useEffect with counterOne dependency or not? It has same functionality. What's the difference?

  • @MuhammadAhmed-wb2sq
    @MuhammadAhmed-wb2sq 2 года назад

    Thanks for those videos.

  • @coderempire3298
    @coderempire3298 2 года назад

    thank you

  • @asadgulzar6249
    @asadgulzar6249 3 года назад

    Best Explaination

  • @priyankaamahour
    @priyankaamahour 3 года назад

    Thank you soo much :) Nice explanation!

  • @igor_cojocaru
    @igor_cojocaru 5 лет назад +1

    Thank you, Sir

  • @sujitsarkar4803
    @sujitsarkar4803 Год назад

    You are superb ❤❤

  • @rajbannasa7662
    @rajbannasa7662 2 года назад

    Thank you so much sir ❤️

  • @saiprasadsaiprasad
    @saiprasadsaiprasad 7 месяцев назад

    where useMemo will cache the result. Is it browser local storage??

  • @ajithkumarv603
    @ajithkumarv603 2 года назад +1

    Wow awesome

  • @khushikothari885
    @khushikothari885 Год назад

    In this particular case, can the delay be reduced without changing the 1st parameter (i.e. function) of useMemo?

  • @ajithkumarv603
    @ajithkumarv603 2 года назад

    Good explanation

  • @sudeepkumar799
    @sudeepkumar799 4 года назад

    Can't stop rerenderings if i pass the object as prop to child component. How can i do that?

  • @djangoboy3840
    @djangoboy3840 3 года назад

    Nice explanation but i have a question you converted even function to "value" to be returned but what if "even" function logic depends on "some parameters being passed from child" and it has to remain as function && this function can be utilized by many childs and can return the value as per the passed paramamters from child. what do we use then useCallback or useMemo. i am bit confused please help me.

  • @patshalaaa
    @patshalaaa Год назад

    Awesome

  • @tiagocunhafernandes6607
    @tiagocunhafernandes6607 5 лет назад

    Tnks, very good example

  • @suryapratap4833
    @suryapratap4833 3 года назад

    nicely explained

  • @bushranikhat2326
    @bushranikhat2326 2 года назад

    Awesome man

  • @TrainExplore
    @TrainExplore 4 года назад +2

    I dun know but counter counter counter
    This is sometimes not clear at all
    Example should be little bit complex

  • @benny-shen
    @benny-shen 20 дней назад

    great

  • @yaqubyusuf2834
    @yaqubyusuf2834 4 года назад

    Great Tutorial

  • @randomcodmobile6205
    @randomcodmobile6205 2 года назад

    will the useEffect with counterOne as dependency work to compute isEven state. Like an alternative to useMemo

  • @boonyaritritdet6364
    @boonyaritritdet6364 4 года назад

    Thank you😊👌

  • @kaveenhyacinth
    @kaveenhyacinth 3 года назад

    Thanks 🤩🤩

  • @0the0ambient0
    @0the0ambient0 4 года назад

    Great, thorough explanation

  • @julio5434
    @julio5434 2 года назад +1

    How to write that equal to 3:29

  • @8ktk
    @8ktk 4 года назад +1

    How would you combine the same function with useCallback and useMemo

  • @bobbyboo1478
    @bobbyboo1478 3 года назад

    Wouldn't this problem be solved if u used useCallback too?

  • @YuHsinShih
    @YuHsinShih 4 года назад +1

    Love the tutorials but I always wonder what other shortcut/snippets you use to make coding more efficient (already installed the ES7/React/Redux ... mentioned). For example, at 1:00, what extension or snippet do you use to make CounterOne, CounterTwo auto change to camelcase if needed? Thank you!

    • @Shubham-xh9nz
      @Shubham-xh9nz 4 года назад +2

      es 7 react/redux graph ql snippet

    • @funworld8379
      @funworld8379 Год назад

      If you have installed es7 snippet extension then just simply type useStateSnippet . It will create the snippet

  • @GonzaloGuevaraFreire
    @GonzaloGuevaraFreire 5 лет назад +1

    Muy buen vídeo

  • @nareshsachin7967
    @nareshsachin7967 2 года назад

    what is the difference between useEffect and useMemo. Anyone please let me know.

  • @carrowkalala9150
    @carrowkalala9150 4 года назад

    thanks

  • @2010lakshitha
    @2010lakshitha 3 года назад

    Isne useEffect the same? when added a dependant parameter it also loads depending on that right?

  • @jasbirsingh-mv5vh
    @jasbirsingh-mv5vh 4 года назад

    so, we could also use useCallback hook, correct????

  • @rkingham3181
    @rkingham3181 2 года назад

    I know React is wanted by many, but let's be fair that a good number of these hooks and techniques are created merely to somehow patch deficiencies in the React core design!

  • @sridharmadala9572
    @sridharmadala9572 2 года назад

    how to type triple equal to and triple not equal to in vs code

  • @varuncharan9109
    @varuncharan9109 2 года назад

    What is cached value ?

  • @ericfox6812
    @ericfox6812 4 года назад

    Sir U didn't call the isEven in counter two

  • @rahulnag9582
    @rahulnag9582 3 года назад

    How to the same in class components??
    Can someone please help me

  • @tanaymainkar1650
    @tanaymainkar1650 3 года назад

    What if I use useCallback for this isEven func works same right??

    • @tanaymainkar1650
      @tanaymainkar1650 3 года назад

      Then why did we have two methods for optimisation

    • @vigneshpugaz8308
      @vigneshpugaz8308 3 года назад +1

      see useCallback is used to cache the function instance.useMemo is a way to cache the function result.Understand the difference.

  • @mohammadhilal8508
    @mohammadhilal8508 3 года назад

    Sir will you please make a video on jwt authentication with react

  • @ramyapriyadarshini7510
    @ramyapriyadarshini7510 4 года назад

    Why would anyone dislike this video? O.o

  • @bobbytop6109
    @bobbytop6109 4 года назад

    why not simply use a call back onClick={()=>incrementTwo};

  • @ramineghbaliankhob9685
    @ramineghbaliankhob9685 3 года назад

    👍👍👍

  • @Tipsy_Nomad
    @Tipsy_Nomad 3 года назад

    looking for this exact example.......

  • @naveennani5928
    @naveennani5928 4 года назад

    👌

  • @ankursinghsolanki9629
    @ankursinghsolanki9629 4 года назад

    what are these khaching values

  • @bhupeshbhatt4334
    @bhupeshbhatt4334 4 года назад

    what do cache mean?

  • @blackpilledbuddha4944
    @blackpilledbuddha4944 4 года назад

    can you make a video on how to implement hoc using hooks

    • @yanaunghein3900
      @yanaunghein3900 3 года назад

      Custom hooks are replacement of HOC, I think

  • @rajashekhar433
    @rajashekhar433 4 года назад

    Looking for Nodejs

  • @wanishoaib_
    @wanishoaib_ Год назад

    even paid courses dont teach this well..

  • @himanshuverma3281
    @himanshuverma3281 Год назад

    Well done bro. Very informative. I have one question. What about memorizing a component and passing an equality check function to use Memo as 2nd argument?
    If you could also put some light on this, that would be really great.

  • @hamed_hafez
    @hamed_hafez Год назад

    great

  • @johnconnor9787
    @johnconnor9787 3 года назад

    Awesome