useMemo Hook in React | #28 React Course

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024

ความคิดเห็น • 12

  • @code75581
    @code75581 ปีที่แล้ว +1

    Great vidéo ! Thanks a lot.
    Please what tool do you use for the animated presentation ? It's really nice.

  • @rishiraj2548
    @rishiraj2548 ปีที่แล้ว

    Thanks

  • @hassanshahid567
    @hassanshahid567 ปีที่แล้ว

    Cant we achieve the same thing by useEffect?

    • @CodewithSloba
      @CodewithSloba  ปีที่แล้ว

      I don’t see how you can achieve the same

    • @hassanshahid567
      @hassanshahid567 ปีที่แล้ว

      @@CodewithSloba actually I'm confused. useEffect and useMemo both take dependency array and are executed when value of dependency array changes so how they are different?

    • @CodewithSloba
      @CodewithSloba  ปีที่แล้ว

      @@hassanshahid567 useMemo executes the function and it caches the result. useCallback caches the instance of function, in case you want to send it as a property to a child. So it doesn't trigger re-render.
      I hope it's clear now

    • @hassanshahid567
      @hassanshahid567 ปีที่แล้ว

      @@CodewithSloba yes!! Thanks 🙏

  • @somith16
    @somith16 ปีที่แล้ว

    isn't it same like usecallback what is the difference between usecallback and usememo??????

    • @CodewithSloba
      @CodewithSloba  ปีที่แล้ว

      it’s not the same, useMemo caches the result of the function, but useCallback caches the function without executing.
      You use useCallback when you want to pass a function as a prop

    • @somith16
      @somith16 ปีที่แล้ว

      @@CodewithSloba thanks 🙏