What is the difference between "UI tree" and "render tree" in the docs?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, react
- Lĩnh vực
- documentation
Hướng nghiên cứu
So sánh thuật ngữ và các ví dụ trong “Your UI as a Tree”, “Preserving and Resetting State” và “Passing Data Deeply with Context”, bao gồm các cách sử dụng được ghi lại của “UI tree” và “render tree”. Bắt đầu bằng việc đạt được sự đồng thuận về việc nên phân biệt hay hợp nhất các thuật ngữ; được coi là hoàn thành khi có một quyết định về thuật ngữ đã được thống nhất và có thể định hướng cho một PR tài liệu tiếp theo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 11.8k
- Fork
- 7.9k
- Merge trung bình
- 16 giờ 6 phút
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của reactjs/react.dev
-
type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
bug: unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
type: typos
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
bug: unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100