DEV Community

Discussion on: when to use useCallback/useMemo

Collapse
 
tarwatuddin profile image
Tarwat Uddin

I agree with the view that functions (with/without props) used in components, in general, should be wrapped in a useCallback function if only you intend to prevent unnecessary re-renders as you've mentioned. However there are some exceptions, if say, it won't lead to much significant performance.

As the developer, how would you know that?

Therefore, I think that this then comes down to on behalf of the developer to use their "programming wisdom" to either include it or not.

BTW: Adding comments to suggest the developer who wishes to use such function props is not so much of a bad idea :¬)