wrap functions you return in useCallback hook

Опубликовано: 26 Июль 2026
на канале: LifeLoveAndMonads
217
9

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())