Q9: What is React.memo and how does it optimize performance?

React.memo is a higher-order component that memoizes functional components. It skips re-rendering a component if its incoming props have not changed according to a shallow equality check.

Key Takeaways
  • React.memo prevents unnecessary re-renders of functional components when props remain identical.

  • Uses shallow comparison by default for prop diffing.

Knowledge Check

What type of comparison does React.memo perform on props by default?