'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.

  1. when your component get mounted initially
  2. when state got changed using this.setState()
  3. when your component receives new props
  4. 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