'when does the `render()` method in react get called
As far as I know these are the scenarios when react calls the render() method provided shouldComponentUpdate() is not implemented.
- when your component get mounted initially
- when state got changed using
this.setState() - when your component receives new
props - when
this.forceUpdate()get called.
Is there any other scenarios that I am missing?
Solution 1:[1]
Yes there's one more case I can think of. When parent component is re-render.
Every time a component is re-render all its children get re-render too. Unless you implement shouldComponentUpdate method in the children.
Hope it helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | agusgar |
