最好通过react-router:setRouteLeaveHook处理。
componentWillMount() { this.unregisterLeaveHook = props.router.setRouteLeaveHook(props.route, this.routerWillLeave.bind(this));}routerWillLeave(nextLocation) { return false; }并且在卸载组件时,取消注册离开钩子:
componentWillUnmount() { this.unregisterLeaveHook();}


