Back to Browse

useCallback hook and when I always use it

2.7K views
Nov 24, 2023
6:34

In this video I show CONTRIVED (but based on the real-world) example of when I use useCallback while writing my react hooks. TLDR; - I always use it when I return a function from custom React hook if it was declared in that hook, since my hook user might decide to put it into dependency array of useEffect which will cause issue shown on the video. - I need to pass function declared inside the component as a prop and that component or one of its children will be memoize (using React.memo()) Also I only briefly touch when I would also use useCallback personally, so, please check new react docs on the subject: https://react.dev/reference/react/useCallback#skipping-re-rendering-of-components There are also other great videos available, my favourite is https://www.youtube.com/shorts/InnDVEup61U Find me on Facebook: https://www.facebook.com/lifeloveandmonads

Download

0 formats

No download links available.

useCallback hook and when I always use it | NatokHD