0 votes
in ReactJS by
What will happen if you use setState() in constructor?

1 Answer

0 votes
by

When you use setState(), then apart from assigning to the object state React also re-renders the component and all its children. You would get error like this: Can only update a mounted or mounting component. So we need to use this.state to initialize variables inside constructor.

Related questions

0 votes
asked Jul 28, 2023 in MemCached by sharadyadav1986
0 votes
asked Jan 18, 2020 in Machine Learning by sharadyadav1986
...