What will happen if you use setState in constructor?
- It will cause a memory leak
- It will cause an error
- It will update the component state
- Nothing
If you use setState in a component's constructor, it will update the component's state. However, this is generally not recommended, as it can cause problems with initialization and lead to confusing code. It is better to set the initial state in the constructor using the this.state property.
Loading...