From 23bf6bed4a67ef63bc037650b5069e44c70ae0a8 Mon Sep 17 00:00:00 2001 From: Leonid Shevtsov Date: Wed, 1 Jul 2015 17:37:57 +0300 Subject: [PATCH] guard setState so that it is not called when the container is already unmounted --- src/lib/createContainer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/createContainer.js b/src/lib/createContainer.js index fd977d2..dcc2b28 100644 --- a/src/lib/createContainer.js +++ b/src/lib/createContainer.js @@ -111,7 +111,9 @@ module.exports = function (Component, options) { return; } try { - _this.setState(queryResults); + // See discussion at https://github.com/facebook/react/issues/2787 + if (_this.isMounted()) + _this.setState(queryResults); } catch (error) { // Call to setState may fail if renderToString() was used.