I Love ReactJS

The difference between memo and useMemo react

difference between memo and useMemo react

Let's start with the conclusion:

React.memo () & nbsp Is a high-level component (HOC) , which takes a component An as a parameter and returns a component B if the props (or the value in it) of component B has not changed Component B prevents component A from re-rendering.

The difference is that useMemo is a hook, and its idea is similar to that of memo, while the second parameter of useMemo is an array, which is used to determine whether to update the callback function .

Exit mobile version