What is the difference between "UI tree" and "render tree" in the docs?
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 11.8k
- 分支
- 7.9k
- 平均合併
- 1 天 11 小時
- 30 天內合併 PR
- 11
描述
Recently an article called "Your UI as a Tree" has been added, introducing a new concept called "render tree". However, the React docs have been using a similar term, "UI tree", such as in the article "Preserving and Resetting State" and "Passing Data Deeply with Context" where this term appears many times.
Are these exactly the same concept? Or are they different? Initially, I thought that they were the same concept, at least in the context of how React and ReactDOM work. But could they actually be different?
My current understanding is as follows:
- JSX tree: The nested JSX tag hierarchy that developers can return from a component.
- Render tree: The component hierarchy in a single pass of React rendering. This concept exists in the core React code, not ReactDOM. A new one is created for each render pass.
- DOM tree: The tree of browser DOM elements you can traverse with
querySelectorAll(), etc.. Changes over time as a result of the commit. - UI tree: ???
The question here is, "Is a render tree immutable?" According to "Your UI as a Tree", a render tree is an immutable data structure corresponding to a single render pass, like a snapshot of a specific render, traditionally referred to as "virtual DOM" or "(UI) description":
- A render tree represents a single render pass of a React application.
- Although render trees may differ across render passes, ...
It also equates the render tree and the UI tree:
- React creates a UI tree from your components.
- React creates a render tree, a UI tree, composed of the rendered components.
On the other hand, in "Preserving and Resetting State", it says, "React removed the Counter from the UI tree and destroyed its state". This seems to indicate that the UI tree is mutable, hence different from the render tree.
After reviewing the usage of "UI tree" throughout the documentation, my tentative conclusion is that "UI tree" has now become an ambiguous concept that may refer to either a render tree or a DOM tree depending on the context. Now that "render tree" is introduced and clearly defined, the term "UI tree" might be retired from most part of the documentation for the sake of consistency. What do you think?
I understand that such discussions are usually not much of an issue, but I don't want to see the problem of the legacy docs again, where consistency was lost as new articles were added. Once there's some consensus, I would like to create a PR to maintain consistency.
/CC @lunaleaps
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
比較「Your UI as a Tree」、「Preserving and Resetting State」和「Passing Data Deeply with Context」中的術語與範例,包括文件中對「UI tree」和「render tree」的使用。首先就這些術語應該區分還是合併達成共識;完成意味著形成一項已達成共識的術語決策,可為後續的文件 PR 提供指引。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, react
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100