4 reasons React renders: 1


4 reasons React renders:

1. State change
2. Prop change
3. Parent render
4. Context change

When props change or a parent renders, you can skip the render via:
1. shouldComponentUpdate
2. PureComponent
3. React.Memo

When state or context change, React always renders.

#reactjs

Just posted in blog form for sharing. 🙏

Four Reasons React Renders (and three ways to stop it): https://www.bitnative.com/2020/07/16/four-reasons-react-renders-and-three-ways-to-stop-it/
Correction:

When props change or a parent renders, you can skip the render via:

shouldComponentUpdate
PureComponent
React.memo

When state changes, you can skip the render via:

shouldComponentUpdate
React.memo

When context changes, React always renders.

View original on X