score:1

Accepted answer

I would not do this, I would recommend looking at the other lifecycle methods here:

https://reactjs.org/docs/react-component.html

For example, shouldComponentUpdate(), which factors in a boolean value which may prevent re-rendering:

shouldComponentUpdate(nextProps, nextState) {
  if (nextState.name != this.state.name)
    return false;
  return true;
}

Related Query

More Query from same tag