render是纯函数,不能在其中进行判断,可以使用UNSAFE_componentWillMount,就是之前的componentWillMount
UNSAFE_componentWillMount(){
const { isLogin } = this.props;
if (!isLogin) {
message.warning('您需要先登陆');
return (
<Redirect to="/login" />
)
}
}









网友评论