The difference between memo and useMemo react

May 2, 2023 1420hotness 0likes 0comments

difference between memo and useMemo react

Let's start with the conclusion:

  • React.memo () is a high-level component that we can use to wrap components that we don't want to re-render unless the props in it changes

  • useMemo () is a React Hook that we can use to wrap functions in the component. We can use it to ensure that the value in this function is recalculated only when one of its dependencies changes

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 .

InterServer Web Hosting and VPS

Aaron

Hello, my name is Aaron and I am a freelance front-end developer

Comments