Cleanup leave hook

This commit is contained in:
Chi Vinh Le
2018-05-01 16:19:47 +02:00
parent e8cd938b65
commit fd3f5e5116
@@ -21,6 +21,7 @@ import { withRouter } from 'react-router';
class ConfigureContainer extends React.Component {
nextRoute = '';
unregisterLeaveHook = null;
savePending = async () => {
await this.props.updateSettings(this.props.pending);
@@ -71,7 +72,14 @@ class ConfigureContainer extends React.Component {
};
componentDidMount() {
this.props.router.setRouteLeaveHook(this.props.route, this.routeLeave);
this.unregisterLeaveHook = this.props.router.setRouteLeaveHook(
this.props.route,
this.routeLeave
);
}
componentWillUnmount() {
this.unregisterLeaveHook();
}
render() {