DEV Community

Cover image for React memo - Performance Optimization
Manikandan K
Manikandan K

Posted on

React memo - Performance Optimization

React.memo(Component)

Performance optimization is an important factor in web development.
React.memo as a higher-order component used for optimizing functional components by memoizing their output.
React uses “memoization” as an optimization technique to speed up the rendering process of the components.

  • React.memo() was introduced with React 16.6 to avoid unnecessary re-renders in functional components.
  • It is a higher-order component that accepts another component as a prop.
  • It will only render the component if there is any change in the props.
  • Here, the parent renders again anytime I make a change to its state in the parent component. A child is also rendered again. However, there are no modifications or effects for youngsters. Extraneous rework.

Image description

Image description

Image description

Here, the parent renders again anytime I make a change to its state in the parent component. A child is also rendered again. However, there are no modifications or effects for youngsters. Extraneous rework.

React.memo(ChildComponent)

My child component is wrapped to React.memo (child) in this instance. It is therefore rendered only when my props for this child change.

Image description

Image description

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay