react 的函数组件每次渲染执行两次
这是 React的刻意为之,并发模式下在dev 时render-phase会执行两次。原因 Dan 在下面解释了
https://github.com/facebook/react/issues/17786
https://github.com/facebook/react/issues/17786
意思是在开发环境下函数组建会执行两次,以及setState之后也会执行两次。
引用 :
为什么 react 的函数组件每次渲染执行两次? - 知乎
问的可能比较模糊,show the code 吧。比如我有这么一个组件:let count = 0function App() { const …
https://www.zhihu.com/question/387196401