about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authoralpaca-tc <alpaca-tc@alpaca.tc>2017-06-21 03:37:09 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-20 20:37:09 +0200
commit1fc6cb499742c1a872ad717a689c58a80aeb714d (patch)
treedae67571390444b76e3f65549d40a77eac60128b /app
parenteb832e88f44d661a504a091defc051e052eb1252 (diff)
Do not call setState from unmounted component (#3853)
Stop an executing task if the component already unmounted.
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/components/status.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js
index 17f2eb9d3..8c4443967 100644
--- a/app/javascript/mastodon/components/status.js
+++ b/app/javascript/mastodon/components/status.js
@@ -86,6 +86,8 @@ class Status extends ImmutablePureComponent {
       this.node,
       this.handleIntersection
     );
+
+    this.componentMounted = true;
   }
 
   componentWillUnmount () {
@@ -96,6 +98,8 @@ class Status extends ImmutablePureComponent {
     }
 
     this.props.intersectionObserverWrapper.unobserve(this.props.id, this.node);
+
+    this.componentMounted = false;
   }
 
   handleIntersection = (entry) => {
@@ -116,6 +120,10 @@ class Status extends ImmutablePureComponent {
   }
 
   hideIfNotIntersecting = () => {
+    if (!this.componentMounted) {
+      return;
+    }
+
     // When the browser gets a chance, test if we're still not intersecting,
     // and if so, set our isHidden to true to trigger an unrender. The point of
     // this is to save DOM nodes and avoid using up too much memory.