-
Notifications
You must be signed in to change notification settings - Fork 115
feat(i18n): translate src/content/learn/describing-the-ui.md from English to Vietnamese #475
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
34bd069
a354e79
aeb8014
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,30 +1,30 @@ | ||||||
--- | ||||||
title: Describing the UI | ||||||
title: Mô tả UI | ||||||
--- | ||||||
|
||||||
<Intro> | ||||||
|
||||||
React is a JavaScript library for rendering user interfaces (UI). UI is built from small units like buttons, text, and images. React lets you combine them into reusable, nestable *components.* From web sites to phone apps, everything on the screen can be broken down into components. In this chapter, you'll learn to create, customize, and conditionally display React components. | ||||||
React là một thư viện JavaScript để render giao diện người dùng (UI). UI được xây dựng từ những đơn vị nhỏ như nút bấm, văn bản và hình ảnh. React cho phép bạn kết hợp chúng thành những *component* có thể tái sử dụng và lồng ghép. Từ trang web đến ứng dụng điện thoại, mọi thứ trên màn hình đều có thể được chia nhỏ thành component. Trong chương này, bạn sẽ học cách tạo, tùy chỉnh và hiển thị React component theo điều kiện. | ||||||
|
||||||
</Intro> | ||||||
|
||||||
<YouWillLearn isChapter={true}> | ||||||
|
||||||
* [How to write your first React component](/learn/your-first-component) | ||||||
* [When and how to create multi-component files](/learn/importing-and-exporting-components) | ||||||
* [How to add markup to JavaScript with JSX](/learn/writing-markup-with-jsx) | ||||||
* [How to use curly braces with JSX to access JavaScript functionality from your components](/learn/javascript-in-jsx-with-curly-braces) | ||||||
* [How to configure components with props](/learn/passing-props-to-a-component) | ||||||
* [How to conditionally render components](/learn/conditional-rendering) | ||||||
* [How to render multiple components at a time](/learn/rendering-lists) | ||||||
* [How to avoid confusing bugs by keeping components pure](/learn/keeping-components-pure) | ||||||
* [Why understanding your UI as trees is useful](/learn/understanding-your-ui-as-a-tree) | ||||||
* [Cách viết React component đầu tiên của bạn](/learn/your-first-component) | ||||||
* [Khi nào và cách tạo file multi-component](/learn/importing-and-exporting-components) | ||||||
* [Cách thêm markup vào JavaScript với JSX](/learn/writing-markup-with-jsx) | ||||||
* [Cách sử dụng dấu ngoặc nhọn với JSX để truy cập chức năng JavaScript từ component của bạn](/learn/javascript-in-jsx-with-curly-braces) | ||||||
* [Cách cấu hình component với props](/learn/passing-props-to-a-component) | ||||||
* [Cách render component theo điều kiện](/learn/conditional-rendering) | ||||||
* [Cách render nhiều component cùng lúc](/learn/rendering-lists) | ||||||
* [Cách tránh bug khó hiểu bằng cách giữ component thuần khiết](/learn/keeping-components-pure) | ||||||
* [Tại sao hiểu UI của bạn như cây cấu trúc lại hữu ích](/learn/understanding-your-ui-as-a-tree) | ||||||
|
||||||
</YouWillLearn> | ||||||
|
||||||
## Your first component {/*your-first-component*/} | ||||||
## Component đầu tiên của bạn {/*your-first-component*/} | ||||||
|
||||||
React applications are built from isolated pieces of UI called *components*. A React component is a JavaScript function that you can sprinkle with markup. Components can be as small as a button, or as large as an entire page. Here is a `Gallery` component rendering three `Profile` components: | ||||||
Ứng dụng React được xây dựng từ những phần UI tách biệt gọi là *component*. Một React component là một JavaScript function mà bạn có thể rắc thêm markup. Component có thể nhỏ như một nút bấm, hoặc lớn như toàn bộ trang. Đây là một component `Gallery` render ba component `Profile`: | ||||||
|
||||||
<Sandpack> | ||||||
|
||||||
|
@@ -58,13 +58,13 @@ img { margin: 0 10px 10px 0; height: 90px; } | |||||
|
||||||
<LearnMore path="/learn/your-first-component"> | ||||||
|
||||||
Read **[Your First Component](/learn/your-first-component)** to learn how to declare and use React components. | ||||||
Đọc **[Component Đầu Tiên Của Bạn](/learn/your-first-component)** để học cách khai báo và sử dụng React component. | ||||||
|
||||||
</LearnMore> | ||||||
|
||||||
## Importing and exporting components {/*importing-and-exporting-components*/} | ||||||
## Import và export component {/*importing-and-exporting-components*/} | ||||||
|
||||||
You can declare many components in one file, but large files can get difficult to navigate. To solve this, you can *export* a component into its own file, and then *import* that component from another file: | ||||||
Bạn có thể khai báo nhiều component trong một file, nhưng file lớn có thể khó điều hướng. Để giải quyết điều này, bạn có thể *export* một component vào file riêng của nó, và sau đó *import* component đó từ file khác: | ||||||
|
Bạn có thể khai báo nhiều component trong một file, nhưng file lớn có thể khó điều hướng. Để giải quyết điều này, bạn có thể *export* một component vào file riêng của nó, và sau đó *import* component đó từ file khác: | |
Bạn có thể khai báo nhiều component trong một file, nhưng file quá nhiều component có thể khó sử dụng. Để giải quyết điều này, bạn có thể *export* một component vào file riêng của nó, và sau đó *import* component đó từ file khá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.
Mỗi React component là một JavaScript function có thể chứa một số markup mà React render vào trình duyệt. React component sử dụng phần mở rộng cú pháp được gọi là JSX để biểu diễn markup đó. JSX trông rất giống HTML, nhưng nó nghiêm ngặt hơn một chút và có thể hiển thị thông tin động. | |
Mỗi React component là một JavaScript function có thể chứa một số markup mà React render vào trình duyệt. React component sử dụng phần mở rộng cú pháp được gọi là JSX để hiện thị markup đó. JSX trông rất giống HTML, nhưng nó nghiêm ngặt hơn một chút và có thể hiển thị thông tin một cách linh động. |
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ếu chúng ta dán markup HTML hiện có vào một React component, nó sẽ không phải lúc nào cũng hoạt động: | |
Nếu chúng ta dùng y hệt markup HTML vào một React component, nó chưa chắc sẽ hoạt động: |
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ếu bạn có HTML hiện có như thế này, bạn có thể sửa nó bằng cách sử dụng [trình chuyển đổi](https://transform.tools/html-to-jsx): | |
Nếu bạn hiện có HTML như thế này, bạn có thể sửa nó bằng cách sử dụng [trình chuyển đổi](https://transform.tools/html-to-jsx): |
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.
JSX cho phép bạn viết markup giống HTML bên trong file JavaScript, giữ logic render và nội dung ở cùng một nơi. Đôi khi bạn sẽ muốn thêm một chút logic JavaScript hoặc tham chiếu đến một thuộc tính động bên trong markup đó. Trong tình huống này, bạn có thể sử dụng dấu ngoặc nhọn trong JSX để "mở cửa sổ" đến JavaScript: | |
JSX cho phép bạn viết markup giống HTML bên trong file JavaScript, để giữ logic render và nội dung ở cùng một nơi. Đôi khi bạn sẽ muốn thêm một chút logic JavaScript hoặc tham chiếu đến một thuộc tính động bên trong markup đó. Trong tình huống này, bạn có thể sử dụng dấu ngoặc nhọn trong JSX để "mở cửa sổ" đến JavaScript: |
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.
* **Chỉ quan tâm đến công việc của mình.** Nó không thay đổi bất kỳ object hoặc biến nào đã tồn tại trước khi nó được gọi. | |
* **Chỉ quan tâm đến công việc của nó.** Nó không thay đổi bất kỳ object hoặc biến nào đã tồn tại trước khi nó được gọi. |
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.
Bằng cách chỉ viết component của bạn như các function thuần khiết một cách nghiêm ngặt, bạn có thể tránh được cả một loại bug khó hiểu và hành vi không thể dự đoán khi codebase của bạn phát triển. Đây là một ví dụ về component không thuần khiết: | |
Bằng cách chỉ viết component của bạn như các function thuần khiết một cách nghiêm ngặt, bạn có thể tránh được một loạt bug khó hiểu và hành vi khó đoán khi codebase của bạn ngày càng lớn. Đây là một ví dụ về component không thuần khiết: |
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.
Đọc **[Giữ Component Thuần Khiết](/learn/keeping-components-pure)** để học cách viết component như những function thuần khiết, có thể dự đoán được. | |
Đọc **[Giữ Component Thuần Khiết](/learn/keeping-components-pure)** để học cách viết component như những function thuần khiết, dễ dự đoá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.
## UI của bạn như một cây cấu trúc {/*your-ui-as-a-tree*/} | |
## UI của bạn theo cấu trúc cây {/*your-ui-as-a-tree*/} |
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 React render tree là sự biểu diễn của mối quan hệ cha và con giữa các component. | |
Một React render tree là sự biểu hiện của mối quan hệ cha và con giữa các component. |
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.
Component gần đỉnh của cây, gần root component, được coi là component cấp cao nhất. Component không có component con là leaf component. Việc phân loại component này hữu ích để hiểu luồng dữ liệu và hiệu suất render. | |
Component gần đỉnh của cây, gần root component, được coi là component cấp cao nhất. Component không có component con là leaf (lá) component. Việc phân loại các component này hữu ích để hiểu luồng dữ liệu và hiệu suất render. |
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.
Đọc **[UI Của Bạn Như Một Cây](/learn/understanding-your-ui-as-a-tree)** để học cách tạo render tree và module dependency tree cho ứng dụng React và cách chúng là những mô hình tinh thần hữu ích để cải thiện trải nghiệm người dùng và hiệu suất. | |
Đọc **[UI Của Bạn Như Một Cây](/learn/understanding-your-ui-as-a-tree)** để học cách tạo render tree và module dependency tree cho ứng dụng React và cách chúng là những mô hình tư duy hữu ích để cải thiện trải nghiệm người dùng và hiệu suất. |
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.