From fd3f5e511625a83d451547f05840834e878ed657 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 1 May 2018 16:19:47 +0200 Subject: [PATCH] Cleanup leave hook --- .../src/routes/Configure/containers/Configure.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Configure/containers/Configure.js b/client/coral-admin/src/routes/Configure/containers/Configure.js index 73e643343..4910a2ec4 100644 --- a/client/coral-admin/src/routes/Configure/containers/Configure.js +++ b/client/coral-admin/src/routes/Configure/containers/Configure.js @@ -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() {