this.setState() in componentDidMount throws error


#1

Hi,

did not find anything similar or a solution in this forum, so i’m asking you for help!

I’m currently using react and react-router@v4 for a new meteor project. While using this.setState() ind the Meteor lifecycle-method componentDidmount() i get the following error message in console:

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. [...]

Doesn’t componentDidmount() guarantee me that the component is mounted?

Any possible solutions for getting this.state back to work?


#2

Can you show your code for the component in question?