Do not call setState from unmounted component (#3853)
Stop an executing task if the component already unmounted.
This commit is contained in:
parent
eb832e88f4
commit
1fc6cb4997
@ -86,6 +86,8 @@ class Status extends ImmutablePureComponent {
|
|||||||
this.node,
|
this.node,
|
||||||
this.handleIntersection
|
this.handleIntersection
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.componentMounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
@ -96,6 +98,8 @@ class Status extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.props.intersectionObserverWrapper.unobserve(this.props.id, this.node);
|
this.props.intersectionObserverWrapper.unobserve(this.props.id, this.node);
|
||||||
|
|
||||||
|
this.componentMounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleIntersection = (entry) => {
|
handleIntersection = (entry) => {
|
||||||
@ -116,6 +120,10 @@ class Status extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideIfNotIntersecting = () => {
|
hideIfNotIntersecting = () => {
|
||||||
|
if (!this.componentMounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// When the browser gets a chance, test if we're still not intersecting,
|
// 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
|
// 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.
|
// this is to save DOM nodes and avoid using up too much memory.
|
||||||
|
Loading…
Reference in New Issue
Block a user