React: How to prevent components from re-rendering?

Please SUBSCRIBE my YouTube Channel: FrontEnd Interview Preparation: https://www.youtube.com/channel/UC-elmWUfbcbmvuhlS12nCtg

This is one of the most frequently asked questions,

  1. shouldComponentUpdate() — returns ‘true’ by default. You can override if you know which props have to trigger an update.
  2. PureComponents — The difference between them is that React.Component doesn’t implement shouldComponentUpdate method but React.PureComponentimplements it with a shallow prop and state comparison.
  3. React.memo — The same as the previous one but it works with functional components.

Keep learning, Keep growing!

Let’s connect on LinkedIn!

Don’t forget to follow me on medium for more updates.

--

--