React Hooks Tutorial - 27 - useMemo Hook

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 115

  • @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 роки тому +22

      ​@@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 років тому +49

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

  • @yuudaemones2624
    @yuudaemones2624 3 роки тому +5

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

  • @jackwhite5070
    @jackwhite5070 4 роки тому +3

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

  • @mandihaase2744
    @mandihaase2744 3 роки тому +6

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

  • @karthickramachandran4701
    @karthickramachandran4701 5 років тому +43

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

  • @ozzyfromspace
    @ozzyfromspace 3 роки тому +1

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

  • @SpinningPsycho
    @SpinningPsycho 2 роки тому

    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

  • @conaxliu9677
    @conaxliu9677 5 років тому +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 4 роки тому +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 11 місяців тому

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

  • @rajadastidar3765
    @rajadastidar3765 4 роки тому +2

    Man you have a very conceptual knowledge.

  • @sabbasachisaha
    @sabbasachisaha 4 роки тому

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

  • @bhaktisagarwithankit
    @bhaktisagarwithankit 3 роки тому +1

    Your every example is awesome, clear

  • @shshawon39
    @shshawon39 4 роки тому +1

    Your Teaching style is awesome!

  • @RichardAK
    @RichardAK Рік тому

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

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

  • @VinayK22
    @VinayK22 5 років тому +1

    absolutely nailing the tutorials, best on youtube

  • @AtulSharma-mo4od
    @AtulSharma-mo4od 2 роки тому

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

  • @himanshushekhar3694
    @himanshushekhar3694 4 роки тому +1

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

  • @adityabhosale4446
    @adityabhosale4446 4 місяці тому

    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

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

  • @bouyahyabilel2437
    @bouyahyabilel2437 4 роки тому +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])

  • @fazliddinfayziev-qg1vg
    @fazliddinfayziev-qg1vg Рік тому

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

  • @samiRediAmaniTekeshAlazar
    @samiRediAmaniTekeshAlazar 2 роки тому

    thank you as always , simple and straight forward

  • @sangitakumre3294
    @sangitakumre3294 4 роки тому

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

  • @ichigoplayss376
    @ichigoplayss376 2 роки тому

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

  • @VitraagShramanSanskriti
    @VitraagShramanSanskriti 2 роки тому

    Best and easy to capture explanation

  • @YuHsinShih
    @YuHsinShih 5 років тому +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

  • @Arunprabu-z1k
    @Arunprabu-z1k 20 днів тому

    Excellent Explanation.

  • @sanatanShishya1521
    @sanatanShishya1521 9 місяців тому

    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.

  • @allensparks6512
    @allensparks6512 2 роки тому

    Amazing. You are the best!

  • @sribalaji7321
    @sribalaji7321 2 роки тому +1

    Best tutorial 🔥

  • @mddulalmiah8012
    @mddulalmiah8012 Рік тому

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

  • @MuhammadAhmed-wb2sq
    @MuhammadAhmed-wb2sq 2 роки тому

    Thanks for those videos.

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

  • @shinaspk9276
    @shinaspk9276 6 місяців тому

    great explanation

  • @priyankaamahour
    @priyankaamahour 4 роки тому

    Thank you soo much :) Nice explanation!

  • @sujitsarkar4803
    @sujitsarkar4803 2 роки тому

    You are superb ❤❤

  • @igor_cojocaru
    @igor_cojocaru 5 років тому +1

    Thank you, Sir

  • @rajbannasa7662
    @rajbannasa7662 3 роки тому

    Thank you so much sir ❤️

  • @0the0ambient0
    @0the0ambient0 4 роки тому

    Great, thorough explanation

  • @ajithkumarv603
    @ajithkumarv603 3 роки тому

    Good explanation

  • @julio5434
    @julio5434 3 роки тому +1

    How to write that equal to 3:29

  • @enucar
    @enucar 4 роки тому +1

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

  • @tiagocunhafernandes6607
    @tiagocunhafernandes6607 5 років тому

    Tnks, very good example

  • @asadgulzar6249
    @asadgulzar6249 3 роки тому

    Best Explaination

  • @bushranikhat2326
    @bushranikhat2326 3 роки тому

    Awesome man

  • @yaqubyusuf2834
    @yaqubyusuf2834 4 роки тому

    Great Tutorial

  • @suryapratap4833
    @suryapratap4833 3 роки тому

    nicely explained

  • @shubhrajit2117
    @shubhrajit2117 5 місяців тому

    tysm 💖

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

  • @boonyaritritdet6364
    @boonyaritritdet6364 4 роки тому

    Thank you😊👌

  • @ajithkumarv603
    @ajithkumarv603 3 роки тому +1

    Wow awesome

  • @khushikothari885
    @khushikothari885 2 роки тому

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

  • @randomcodmobile6205
    @randomcodmobile6205 3 роки тому

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

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

  • @8ktk
    @8ktk 4 роки тому +1

    How would you combine the same function with useCallback and useMemo

  • @2010lakshitha
    @2010lakshitha 3 роки тому

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

  • @kaveenhyacinth
    @kaveenhyacinth 3 роки тому

    Thanks 🤩🤩

  • @coderempire3298
    @coderempire3298 2 роки тому

    thank you

  • @sudeepkumar799
    @sudeepkumar799 4 роки тому

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

  • @saiprasadsaiprasad
    @saiprasadsaiprasad 10 місяців тому

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

  • @GonzaloGuevaraFreire
    @GonzaloGuevaraFreire 5 років тому +1

    Muy buen vídeo

  • @mohammadhilal8508
    @mohammadhilal8508 3 роки тому

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

  • @jasbirsingh-mv5vh
    @jasbirsingh-mv5vh 4 роки тому

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

  • @TrainExplore
    @TrainExplore 4 роки тому +2

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

  • @varuncharan9109
    @varuncharan9109 2 роки тому

    What is cached value ?

  • @tanaymainkar1650
    @tanaymainkar1650 4 роки тому

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

    • @tanaymainkar1650
      @tanaymainkar1650 4 роки тому

      Then why did we have two methods for optimisation

    • @vigneshpugaz8308
      @vigneshpugaz8308 4 роки тому +1

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

  • @ericfox6812
    @ericfox6812 4 роки тому

    Sir U didn't call the isEven in counter two

  • @bobbyboo1478
    @bobbyboo1478 3 роки тому

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

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

  • @carrowkalala9150
    @carrowkalala9150 4 роки тому

    thanks

  • @johnconnor9787
    @johnconnor9787 3 роки тому

    Awesome

  • @ramyapriyadarshini7510
    @ramyapriyadarshini7510 4 роки тому

    Why would anyone dislike this video? O.o

  • @nareshsachin7967
    @nareshsachin7967 2 роки тому

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

  • @hamed_hafez
    @hamed_hafez 2 роки тому

    great

  • @sridharmadala9572
    @sridharmadala9572 2 роки тому

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

  • @ankursinghsolanki9629
    @ankursinghsolanki9629 4 роки тому

    what are these khaching values

  • @bhupeshbhatt4334
    @bhupeshbhatt4334 4 роки тому

    what do cache mean?

  • @rahulnag9582
    @rahulnag9582 3 роки тому

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

  • @ramineghbaliankhob9685
    @ramineghbaliankhob9685 3 роки тому

    👍👍👍

  • @Tipsy_Nomad
    @Tipsy_Nomad 3 роки тому

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

  • @naveennani5928
    @naveennani5928 5 років тому

    👌

  • @rajashekhar433
    @rajashekhar433 4 роки тому

    Looking for Nodejs

  • @bobbytop6109
    @bobbytop6109 4 роки тому

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

  • @wanishoaib_
    @wanishoaib_ Рік тому

    even paid courses dont teach this well..

  • @himanshuverma3281
    @himanshuverma3281 2 роки тому

    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.

  • @patshalaaa
    @patshalaaa Рік тому

    Awesome

  • @benny-shen
    @benny-shen 3 місяці тому

    great