react-router跳转路有前判断(setRouteLeav
2017-09-11 本文已影响0人
Evan_zhan
跳转路由前做判断,决定是否跳转
this.context.router.setRouteLeaveHook(
this.props.route,
()=> {
if (this.state.uploadFinish === false) {
return '上传未完成,确认退出?';
}
})
声明类型:
Uploading.contextTypes = {
router: React.PropTypes.object
}