-
Notifications
You must be signed in to change notification settings - Fork 5
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
[讨论] React dapp 模板默认禁用 StrictMode 是否更合适 ? #117
Comments
看了篇文章,描述 useEffect 的:https://mp.weixin.qq.com/s/h7GiH_s8e8wM0CDS_tF_3w 综合下来的意思是:
在以上两点的基础之上,不管组件被重复挂载几次,都不会影响当前组件的渲染结果 虽然上面的解释是行得通的,但我个人感觉组件被挂载两次仍然是一个令人充满疑惑的情况,个人也赞成移除 StrictMode |
讨论结果:移除 |
mark |
启用 StrictMode 后,dev 环境下
useEffect(() => { ... }, [])
中的代码会执行 2 次, 感觉不便于调试.另外, 我们也比较习惯在 useEffect 中 fetch data, 短期内应该也不会使用像下面 comment 里推荐的 React Query
参考: facebook/react#24502 (comment)
The text was updated successfully, but these errors were encountered: