4 ms·
React will rerender the child component anyway in this case even with useCallback. Of course you can prevent this by using React.Memo on the child component, an
by fabian2k 4y ago
React will rerender the child component anyway in this case even with useCallback. Of course you can prevent this by using React.Memo on the child component, and in this case using useCallback makes it possible to optimize rerendering by providing stable values for functions you pass to that component.
Adding useCallback for functions only does something useful if you also React.Memo those children. So while this is a very important optimization, it's not one you need to apply to everything.