When does React decide to re-render a component ?
- The first rendering will be triggered after the componentWillMount lifecycle.
- After the React ComponentWillUpdate lifecycle, it is then activated.
- After mounting a React component, it will listen to any React props or state that has changed.
- It will, by default, re-render the entire React component and its child components when it detects something has changed.
How to solve too many re-renders error in ReactJS?
“Too many re-renderers” is a React error that happens after you have reached an infinite render loop, typically caused by code that in a useEffect hook or the main body of the component itself unconditionally calls state setters.