-
Notifications
You must be signed in to change notification settings - Fork 115
feat(i18n): translate src/content/learn/understanding-your-ui-as-a-tree.md from English to Vietnamese #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,41 +1,41 @@ | ||||||
--- | ||||||
title: Understanding Your UI as a Tree | ||||||
title: Hiểu giao diện người dùng theo cấu trúc cây | ||||||
--- | ||||||
|
||||||
<Intro> | ||||||
|
||||||
Your React app is taking shape with many components being nested within each other. How does React keep track of your app's component structure? | ||||||
Ứng dụng React của bạn đang thành hình với nhiều component được lồng trong nhau. React theo dõi cấu trúc component của ứng dụng như thế nào? | ||||||
|
||||||
React, and many other UI libraries, model UI as a tree. Thinking of your app as a tree is useful for understanding the relationship between components. This understanding will help you debug future concepts like performance and state management. | ||||||
React, và nhiều thư viện UI khác, mô hình hóa UI theo cấu trúc cây. Nghĩ về ứng dụng của bạn theo cấu trúc cây rất hữu ích để hiểu mối quan hệ giữa các component. Sự hiểu biết này sẽ giúp bạn debug các khái niệm trong tương lai như hiệu năng và quản lý state. | ||||||
|
||||||
</Intro> | ||||||
|
||||||
<YouWillLearn> | ||||||
|
||||||
* How React "sees" component structures | ||||||
* What a render tree is and what it is useful for | ||||||
* What a module dependency tree is and what it is useful for | ||||||
* React "nhìn" cấu trúc component như thế nào | ||||||
* Render tree là gì và nó hữu ích cho việc gì | ||||||
* Module dependency tree là gì và nó hữu ích cho việc gì | ||||||
|
||||||
</YouWillLearn> | ||||||
|
||||||
## Your UI as a tree {/*your-ui-as-a-tree*/} | ||||||
## Giao diện người dùng theo cấu trúc cây {/*your-ui-as-a-tree*/} | ||||||
|
||||||
Trees are a relationship model between items and UI is often represented using tree structures. For example, browsers use tree structures to model HTML ([DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model/Introduction)) and CSS ([CSSOM](https://developer.mozilla.org/docs/Web/API/CSS_Object_Model)). Mobile platforms also use trees to represent their view hierarchy. | ||||||
Cây là mô hình quan hệ giữa các mục và UI thường được biểu diễn bằng cấu trúc cây. Ví dụ, trình duyệt sử dụng cấu trúc cây để mô hình hóa HTML ([DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model/Introduction)) và CSS ([CSSOM](https://developer.mozilla.org/docs/Web/API/CSS_Object_Model)). Các nền tảng di động cũng sử dụng cây để biểu diễn hệ thống phân cấp view của chúng. | ||||||
|
||||||
<Diagram name="preserving_state_dom_tree" height={193} width={864} alt="Diagram with three sections arranged horizontally. In the first section, there are three rectangles stacked vertically, with labels 'Component A', 'Component B', and 'Component C'. Transitioning to the next pane is an arrow with the React logo on top labeled 'React'. The middle section contains a tree of components, with the root labeled 'A' and two children labeled 'B' and 'C'. The next section is again transitioned using an arrow with the React logo on top labeled 'React DOM'. The third and final section is a wireframe of a browser, containing a tree of 8 nodes, which has only a subset highlighted (indicating the subtree from the middle section)."> | ||||||
|
||||||
React creates a UI tree from your components. In this example, the UI tree is then used to render to the DOM. | ||||||
React tạo ra một cây UI từ các component của bạn. Trong ví dụ này, cây UI sau đó được sử dụng để render ra DOM. | ||||||
</Diagram> | ||||||
|
||||||
Like browsers and mobile platforms, React also uses tree structures to manage and model the relationship between components in a React app. These trees are useful tools to understand how data flows through a React app and how to optimize rendering and app size. | ||||||
Giống như trình duyệt và nền tảng di động, React cũng sử dụng cấu trúc cây để quản lý và mô hình hóa mối quan hệ giữa các component trong ứng dụng React. Những cây này là công cụ hữu ích để hiểu cách dữ liệu chảy qua ứng dụng React và cách tối ưu hóa việc render và kích thước ứng dụng. | ||||||
|
||||||
## The Render Tree {/*the-render-tree*/} | ||||||
## Render Tree {/*the-render-tree*/} | ||||||
|
||||||
A major feature of components is the ability to compose components of other components. As we [nest components](/learn/your-first-component#nesting-and-organizing-components), we have the concept of parent and child components, where each parent component may itself be a child of another component. | ||||||
Một tính năng chính của component là khả năng kết hợp component từ các component khác. Khi chúng ta [lồng component](/learn/your-first-component#nesting-and-organizing-components), chúng ta có khái niệm về component cha và component con, trong đó mỗi component cha có thể là con của component khác. | ||||||
|
||||||
When we render a React app, we can model this relationship in a tree, known as the render tree. | ||||||
Khi chúng ta render một ứng dụng React, chúng ta có thể mô hình hóa mối quan hệ này trong một cây, được gọi là render tree. | ||||||
|
||||||
Here is a React app that renders inspirational quotes. | ||||||
Đây là một ứng dụng React render những câu trích dẫn truyền cảm hứng. | ||||||
|
||||||
<Sandpack> | ||||||
|
||||||
|
@@ -120,32 +120,31 @@ export default [ | |||||
|
||||||
<Diagram name="render_tree" height={250} width={500} alt="Tree graph with five nodes. Each node represents a component. The root of the tree is App, with two arrows extending from it to 'InspirationGenerator' and 'FancyText'. The arrows are labelled with the word 'renders'. 'InspirationGenerator' node also has two arrows pointing to nodes 'FancyText' and 'Copyright'."> | ||||||
|
||||||
React creates a *render tree*, a UI tree, composed of the rendered components. | ||||||
|
||||||
React tạo ra một *render tree*, một cây UI, được tạo thành từ các component đã render. | ||||||
|
||||||
</Diagram> | ||||||
|
||||||
From the example app, we can construct the above render tree. | ||||||
Từ ứng dụng ví dụ, chúng ta có thể xây dựng render tree ở trên. | ||||||
|
||||||
The tree is composed of nodes, each of which represents a component. `App`, `FancyText`, `Copyright`, to name a few, are all nodes in our tree. | ||||||
Cây được tạo thành từ các nút, mỗi nút đại diện cho một component. `App`, `FancyText`, `Copyright`, để kể tên một vài, tất cả đều là các nút trong cây của chúng ta. | ||||||
|
||||||
The root node in a React render tree is the [root component](/learn/importing-and-exporting-components#the-root-component-file) of the app. In this case, the root component is `App` and it is the first component React renders. Each arrow in the tree points from a parent component to a child component. | ||||||
Nút gốc trong render tree của React là [component gốc](/learn/importing-and-exporting-components#the-root-component-file) của ứng dụng. Trong trường hợp này, component gốc là `App` và nó là component đầu tiên mà React render. Mỗi mũi tên trong cây chỉ từ component cha đến component con. | ||||||
|
||||||
<DeepDive> | ||||||
|
||||||
#### Where are the HTML tags in the render tree? {/*where-are-the-html-elements-in-the-render-tree*/} | ||||||
#### Các thẻ HTML ở đâu trong render tree? {/*where-are-the-html-elements-in-the-render-tree*/} | ||||||
|
||||||
You'll notice in the above render tree, there is no mention of the HTML tags that each component renders. This is because the render tree is only composed of React [components](learn/your-first-component#components-ui-building-blocks). | ||||||
Bạn sẽ nhận thấy trong render tree ở trên, không có đề cập đến các thẻ HTML mà mỗi component render. Điều này là do render tree chỉ được tạo thành từ các React [component](learn/your-first-component#components-ui-building-blocks). | ||||||
|
||||||
React, as a UI framework, is platform agnostic. On react.dev, we showcase examples that render to the web, which uses HTML markup as its UI primitives. But a React app could just as likely render to a mobile or desktop platform, which may use different UI primitives like [UIView](https://developer.apple.com/documentation/uikit/uiview) or [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0). | ||||||
React, với tư cách là một framework UI, là platform agnostic. Trên react.dev, chúng tôi trình bày các ví dụ render cho web, sử dụng HTML markup làm UI primitives. Nhưng một ứng dụng React cũng có thể render cho nền tảng di động hoặc desktop, có thể sử dụng các UI primitives khác như [UIView](https://developer.apple.com/documentation/uikit/uiview) hoặc [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0). | ||||||
|
React, với tư cách là một framework UI, là platform agnostic. Trên react.dev, chúng tôi trình bày các ví dụ render cho web, sử dụng HTML markup làm UI primitives. Nhưng một ứng dụng React cũng có thể render cho nền tảng di động hoặc desktop, có thể sử dụng các UI primitives khác như [UIView](https://developer.apple.com/documentation/uikit/uiview) hoặc [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0). | |
React, với tư cách là một framework UI, là platform agnostic (không phụ thuộc vào nền tảng). Trên react.dev, chúng tôi trình bày các ví dụ render cho web, sử dụng HTML markup làm UI primitives. Nhưng một ứng dụng React cũng có thể render cho nền tảng di động hoặc desktop, có thể sử dụng các UI primitives khác như [UIView](https://developer.apple.com/documentation/uikit/uiview) hoặc [FrameworkElement](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement?view=windowsdesktop-7.0). |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Một render tree đại diện cho một lần render duy nhất của ứng dụng React. Với [conditional rendering](/learn/conditional-rendering), một component cha có thể render các con khác nhau tùy thuộc vào dữ liệu được truyền. | |
Một render tree đại diện cho một lần render duy nhất của ứng dụng React. Với [conditional rendering (render theo điều kiện)](/learn/conditional-rendering), một component cha có thể render các con khác nhau tùy thuộc vào dữ liệu được truyền. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nút gốc của cây là root module, còn được gọi là entrypoint file. Nó thường là module chứa component gốc. | |
Nút gốc của cây là root module, còn được gọi là file mở đầu. Nó thường là module chứa component gốc. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Dependency trees hữu ích để debug kích thước bundle lớn làm chậm thời gian vẽ và tìm ra cơ hội để tối ưu hóa mã được bundle. | |
* Dependency trees hữu ích để debug các bundle có kích thước lớn làm chậm thời gian hiện thị và giúp phát hiện cơ hội để tối ưu hóa mã code được bundle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.