-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
componentWillMount里面执行redirectTo, componentDidShow和componentDidMount仍然被执行 #4312
Comments
@dpyzo0o 你可以写份原生试试在 onLoad 跳转还会不会触发 onReady、onShow |
@Chen-jj 试了下,原生的也是会触发 onReady 和 onShow 我想请问一下所以一般这种情况是如何处理的呢?我是需要在 componentWillMount 里面检查是否登录过,未登陆过就跳转登录页,但是在 componentDidMount 和 componentDidShow 里面有需要登录权限的网络请求,这种情况就会报错。 |
@dpyzo0o componentDidMount 和 componentDidShow 里没有登录权限就不请求直接 return 不就行咯 |
@Chen-jj 恩恩,我目前也是这么处理的。但是感觉每个需要登录权限的页面都要在三个生命周期里面检查一下,很繁琐。。 |
@dpyzo0o 试试 hooks 吧,抽一个 useEffect |
@Chen-jj 好的,感谢解答~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
componentWillMount里面执行redirectTo, componentDidShow和componentDidMount仍然被执行
复现步骤
代码截图, 左边为 pages/index, 右边为 pages/login
执行顺序
The text was updated successfully, but these errors were encountered: