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
#669)

`this.editor` might be undefined if error occured during `componentDidMount`, like #665
  • Loading branch information
whtsky authored and Neitsch committed Aug 7, 2019
1 parent 284cecf commit ca226ee
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/graphiql/src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,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() {
Expand Down

0 comments on commit ca226ee

Please sign in to comment.