简体   繁体   English

批量更新在反应中意味着什么?

[英]What does batching update mean in react?

I was reading an article on the setState method.我正在阅读有关 setState 方法的文章。 I found this text," Updates to the DOM don't happen immediately when this.setState is called. React batches updates so elements are re-rendered to the DOM efficiently .".我找到了这篇文章,“当调用 this.setState 时,DOM 的更新不会立即发生。React 批处理更新,以便有效地将元素重新渲染到 DOM 。”。 Can anyone explain what does "batch update" mean?谁能解释一下“批量更新”是什么意思?

It means react doesn't react to any update.这意味着 React 不会对任何更新做出反应。 because that would be inefficient.因为那样效率低下。 What React does is wait for some threshold to do multiple updates at once. React 所做的是等待某个阈值一次进行多个更新。 thats why setState function is asynchronus.这就是为什么setState function 是异步的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM