Can you force a component to re-render without calling setState?
By default, when your component's state or props change, your component will re-render. If your render()
method depends on some other data, you can tell React that the component needs re-rendering by calling forceUpdate()
.
component.forceUpdate(callback);
It is recommended to avoid all uses of forceUpdate()
and only read from this.props
and this.state
in render()
.
January 01, 2022
366
Read more
What is React?
November 06, 2022
ReactJSHow to programmatically trigger click event in React?
November 06, 2022
ReactJS