Both React.memo
and the useMemo
hook allow performance optimizations by reducing recalculation and rerendering. However, they work definitely in that React.memo is used to wrap a functional component and the useMemo
hook can be used on almost any function, even pure calculations. More importantly, useMemo
is typically called from a parent to a child component, while React.memo
is typically called on the declaration of the child itself.
While both have different advantages, one advantage of React.memo
is that it doesn't have to be called from each parent to child relationship. However, with the release of hooks, it seems apparent that React development wants to move towards functional components that use hooks to deal with state, side-effect events, and other effects. While I don't think that the React development team would have the courage or disregard of their user base to remove React.memo
any time in the next 2 years, it makes me wonder if they want end users to stop using React.memo for stylistic reasons. Just as they have kind of passive aggressively moved away from class components in favor of functional components with hooks.
When using functional components with hooks, is the react framework moving away from React.memo
?
Would it be better to get used to using the hook version if one wants to keep up with React best practices in the future?