我正在研究React的内部工作,并且对扩散算法和React纤维之间的差异感到非常困惑
反应纤维和扩散算法如何相互连接?反应纤维使用扩散算法还是我试图连接两个完全不同的概念,因为到目前为止,我所理解的都是和解过程的一部分。我想知道他们的执行顺序或这里是否有重叠。
How do React Fiber and diffing algorithm connect with each other? Does React Fiber use diffing algorithm or am I trying to connect two completely different concepts because so far what I have understood is both are a part of the reconciliation process. I want to know their order of execution or if there is any overlap here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鉴于我的理解,“纤维”(通常使用大写“ F”)架构是指REACT的内部运作,特别是React处理React 18中的React和解的方式
,以调和并调和表示同意的方式。有DOM本身和虚拟DOM,一个轻巧的副本。最终,这两个代表性模型将需要相互同意。虚拟DOM的更改最终必须反映在DOM中,就像将新代码更改反映到整个代码库中一样。因此,这就是和解发挥作用的地方。对帐是确切确定需要更新DOM的哪些部分,并且由特定算法进行的过程。
只要React与DOM合作并且DOM的“正在进行的工作”版本,就必须进行某种形式的和解。
有多种实施此和解的方法,例如有多种实施任何算法的方法。将纤维架构视为内部反应将虚拟DOM与DOM调和的方式。
With my understanding, “Fiber” (usually with a capital "F") architecture is referring to internal workings of React, specifically the way that React handles reconciliation in React 18.
By the book, to reconcile means to bring into agreement. There is the DOM itself and the virtual DOM, a lightweight copy. Eventually these two representational models will need to be brought into agreement with each other. The changes in the Virtual DOM eventually have to be reflected in the DOM, the same way that new code changes are reflected into an entire codebase. And thus, this is where reconciliation comes into play. Reconciliation is the process of figuring out exactly what parts of the DOM need to be updated and it's carried out by a specific algorithm.
As long as React is working with the DOM and a “work in progress” version of the DOM, reconciliation of some sort will be necessary.
There’s various ways to implement this reconciliation like there are various ways to implement any algorithm. Think of fiber architecture as the way in which React internally reconciles the Virtual DOM with the DOM.
了解扩散算法和反应纤维之间的差异需要一些有关内部反应如何工作的上下文。
扩散算法:
反应纤维:
。
)。)。
总而言之,扩散算法是React的对帐过程的特定部分和响应能力。扩散算法只是反应纤维内部运行方式的一个方面。
Understanding the difference between the diffing algorithm and React Fiber requires a bit of context about how React works internally.
Diffing Algorithm:
React Fiber:
In summary, the diffing algorithm is a specific part of React's reconciliation process responsible for computing the differences between old and new UI states, while React Fiber is a more comprehensive reimplementation of the reconciliation algorithm that introduces features like incremental rendering and asynchronous rendering to improve performance and responsiveness. The diffing algorithm is just one aspect of how React Fiber operates internally.