【发布时间】:2022-01-30 02:20:38
【问题描述】:
在使用 window.location.href 重定向后,我在终端上得到了这些编译
wait - compiling /login/verify (client and server)...
wait - compiling /login (client and server)...
它应该去 /login/verify,但因为它而返回 /login。
这是我的重定向代码:
componentWillReceiveProps(nextProps) {
if(nextProps.authCode == '0')
{
// redirect to homepage
setTimeout(() => {
window.location.href = '/'
}, 2000)
} else if(nextProps.authCode == '20') {
setTimeout(() => {
window.location.href = '/register/verify'
}, 2000)
} else if(nextProps.authCode == '30')
{
setTimeout(() => {
window.location.href = '/login/verify'
}, 2000)
} else {
this.setState({
alertLoading: false,
alertFailed: true,
alertMsg: nextProps.authInfo
})
}
}
【问题讨论】:
标签: reactjs redux react-redux next.js redux-persist