ReactRouter 离开页面的钩子

   componentDidMount() {
        this.props.router.setRouteLeaveHook(
            this.props.route,
            this.routerWillLeave
        )
    }

    routerWillLeave(nextLocation) {
        return '确认要离开?';
    }

参考文档:http://www.ruanyifeng.com/blog/2016/05/react_router.html?utm_source=tool.lu

你可能感兴趣的:(react)