Warning: setState(…): Can only update a mounted or mounting component.

I guess you’ve got an event listener perhaps listening for a window resize or something like that and each time your render gets called you see this warning in the console?

The reason is because when you add “.bind(this)” to a method it actually returns a new one and because the previous listener never gets removed (the original isn’t mounted anymore) you get this warning.

To get around this add the following at the start of your code and then replace it in the event listener line:

this.updateDimensions = this.updateDimensions.bind(this);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s