How can you ensure a functional component re-renders only when certain props change?

  • Use the shouldComponentUpdate lifecycle method.
  • Use the memo HOC (Higher Order Component).
  • Use the useEffect hook.
  • Use the render method.
You can ensure that a functional component re-renders only when certain props change by using the memo HOC (Higher Order Component). This is a performance optimization that memoizes the component so that it only re-renders when its props change. The other options are either related to class components (not functional components) or are not specifically designed for this purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *