Skip to content

Commit

Permalink
fix: check this.editor exist before this.editor.off in QueryEditor
Browse files Browse the repository at this point in the history
`this.editor` might be undefined if error occured during `componentDidMount`, like #665
  • Loading branch information
whtsky committed Apr 11, 2018
1 parent 811cf9d commit 82d61fb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ export class QueryEditor extends React.Component {
}

componentWillUnmount() {
this.editor.off('change', this._onEdit);
this.editor.off('keyup', this._onKeyUp);
this.editor.off('hasCompletion', this._onHasCompletion);
this.editor = null;
if (this.editor) {
this.editor.off('change', this._onEdit);
this.editor.off('keyup', this._onKeyUp);
this.editor.off('hasCompletion', this._onHasCompletion);
this.editor = null;
}
}

render() {

This comment has been minimized.

Copy link
@msael

msael Apr 29, 2018

K

Expand Down

0 comments on commit 82d61fb

Please sign in to comment.