【发布时间】:2017-11-10 07:40:15
【问题描述】:
如何使用 react router 3 在 React 组件中进行路由重定向?
如果我使用这样的“守卫”组件:
const GuardContainer = (props) => {
const {ok} = isOk(props)
if (!ok) {
// Redirect here to /not-ok
return null
}
return <WrappedComponent {...props}/>
}
然后 React 抱怨改变状态
在现有状态转换期间无法更新(例如在
render或其他组件的构造函数)。
【问题讨论】:
标签: reactjs react-router