mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 16:14:01 +08:00
fix(composer): Add additional isMounted checks
Resolves this exception: https://gist.github.com/jstejada/a26dc6a7a2896dcef9be3cec60eaecdb
This commit is contained in:
parent
6afd911e81
commit
3411ad320e
1 changed files with 6 additions and 8 deletions
|
@ -27,12 +27,12 @@ function InflatesDraftClientId(ComposedComponent) {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._unmounted = false;
|
||||
this._mounted = true;
|
||||
this._prepareForDraft(this.props.draftClientId);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this._unmounted = true;
|
||||
this._mounted = false;
|
||||
this._teardownForDraft();
|
||||
this._deleteDraftIfEmpty();
|
||||
}
|
||||
|
@ -49,14 +49,12 @@ function InflatesDraftClientId(ComposedComponent) {
|
|||
return;
|
||||
}
|
||||
DraftStore.sessionForClientId(draftClientId).then((session) => {
|
||||
if (this._unmounted) {
|
||||
return;
|
||||
}
|
||||
if (session.draftClientId !== this.props.draftClientId) {
|
||||
return;
|
||||
}
|
||||
const shouldSetState = () =>
|
||||
this._mounted && session.draftClientId === this.props.draftClientId
|
||||
|
||||
if (!shouldSetState()) { return; }
|
||||
this._sessionUnlisten = session.listen(() => {
|
||||
if (!shouldSetState()) { return; }
|
||||
this.setState({draft: session.draft()});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue