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);
Advertisements