Skip to content

Commit

Permalink
Merge pull request #125 from solomon23/handle_unmount
Browse files Browse the repository at this point in the history
Don't call onready on an unmounted component
  • Loading branch information
seeden committed Mar 4, 2019
2 parents 6f53bed + 9941bba commit bdcd7ef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Initialize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ class Initialize extends Component<Props> {
};

componentDidMount() {
this._ismounted = true;
this.prepare();
}

componentWillUnmount() {
this._ismounted = false;
}

async prepare() {
const { onReady, handleInit } = this.props;
const api = await handleInit();
if (onReady) {
if (onReady && this._ismounted) {
onReady(api);
}
}
Expand Down

0 comments on commit bdcd7ef

Please sign in to comment.