mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-29 00:10:54 +05:30
#389: fix react warning about setState on unmounted component
This commit is contained in:
parent
bd31aa1ebf
commit
e91bb09c33
@ -109,6 +109,8 @@ class PanelTransition extends Component {
|
|||||||
panelId: this.props.Body && this.props.Body.type.panelId
|
panelId: this.props.Body && this.props.Body.type.panelId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
timerIds = []; // this is a list of a probably running timeouts to clean on unmount
|
||||||
|
|
||||||
getChildContext() {
|
getChildContext() {
|
||||||
return {
|
return {
|
||||||
auth: this.props.auth,
|
auth: this.props.auth,
|
||||||
@ -121,7 +123,9 @@ class PanelTransition extends Component {
|
|||||||
this.setState({isHeightDirty: false});
|
this.setState({isHeightDirty: false});
|
||||||
|
|
||||||
// wait till transition end
|
// wait till transition end
|
||||||
setTimeout(resolve, 200);
|
this.timerIds.push(
|
||||||
|
setTimeout(resolve, 200)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -148,13 +152,20 @@ class PanelTransition extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (forceHeight) {
|
if (forceHeight) {
|
||||||
|
this.timerIds.push(
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setState({forceHeight: 0});
|
this.setState({forceHeight: 0});
|
||||||
}, 100);
|
}, 100)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.timerIds.forEach((id) => clearTimeout(id));
|
||||||
|
this.timerIds = [];
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {contextHeight, forceHeight} = this.state;
|
const {contextHeight, forceHeight} = this.state;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user