Skip to content

Commit 34bd069

Browse files
committed
feat(i18n): translate src/content/learn/describing-the-ui.md from English to Vietnamese
1 parent 04d3c14 commit 34bd069

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

src/content/learn/describing-the-ui.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
---
2-
title: Describing the UI
2+
title: Mô tả UI
33
---
44

55
<Intro>
66

7-
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.
7+
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.
88

99
</Intro>
1010

1111
<YouWillLearn isChapter={true}>
1212

13-
* [How to write your first React component](/learn/your-first-component)
14-
* [When and how to create multi-component files](/learn/importing-and-exporting-components)
15-
* [How to add markup to JavaScript with JSX](/learn/writing-markup-with-jsx)
16-
* [How to use curly braces with JSX to access JavaScript functionality from your components](/learn/javascript-in-jsx-with-curly-braces)
17-
* [How to configure components with props](/learn/passing-props-to-a-component)
18-
* [How to conditionally render components](/learn/conditional-rendering)
19-
* [How to render multiple components at a time](/learn/rendering-lists)
20-
* [How to avoid confusing bugs by keeping components pure](/learn/keeping-components-pure)
21-
* [Why understanding your UI as trees is useful](/learn/understanding-your-ui-as-a-tree)
13+
* [Cách viết React component đầu tiên của bạn](/learn/your-first-component)
14+
* [Khi nào và cách tạo file multi-component](/learn/importing-and-exporting-components)
15+
* [Cách thêm markup vào JavaScript với JSX](/learn/writing-markup-with-jsx)
16+
* [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)
17+
* [Cách cấu hình component với props](/learn/passing-props-to-a-component)
18+
* [Cách render component theo điều kiện](/learn/conditional-rendering)
19+
* [Cách render nhiều component cùng lúc](/learn/rendering-lists)
20+
* [Cách tránh bug khó hiểu bằng cách giữ component thuần khiết](/learn/keeping-components-pure)
21+
* [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)
2222

2323
</YouWillLearn>
2424

25-
## Your first component {/*your-first-component*/}
25+
## Component đầu tiên của bạn {/*your-first-component*/}
2626

27-
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:
27+
Ứ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`:
2828

2929
<Sandpack>
3030

@@ -58,13 +58,13 @@ img { margin: 0 10px 10px 0; height: 90px; }
5858

5959
<LearnMore path="/learn/your-first-component">
6060

61-
Read **[Your First Component](/learn/your-first-component)** to learn how to declare and use React components.
61+
Đọ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.
6262

6363
</LearnMore>
6464

65-
## Importing and exporting components {/*importing-and-exporting-components*/}
65+
## Import và export component {/*importing-and-exporting-components*/}
6666

67-
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:
67+
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:
6868

6969

7070
<Sandpack>
@@ -113,15 +113,15 @@ img { margin: 0 10px 10px 0; }
113113

114114
<LearnMore path="/learn/importing-and-exporting-components">
115115

116-
Read **[Importing and Exporting Components](/learn/importing-and-exporting-components)** to learn how to split components into their own files.
116+
Đọc **[Import và Export Component](/learn/importing-and-exporting-components)** để học cách tách component vào file riêng của chúng.
117117

118118
</LearnMore>
119119

120-
## Writing markup with JSX {/*writing-markup-with-jsx*/}
120+
## Viết markup với JSX {/*writing-markup-with-jsx*/}
121121

122-
Each React component is a JavaScript function that may contain some markup that React renders into the browser. React components use a syntax extension called JSX to represent that markup. JSX looks a lot like HTML, but it is a bit stricter and can display dynamic information.
122+
Mỗi React component là một JavaScript function có thể chứa một số markup 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.
123123

124-
If we paste existing HTML markup into a React component, it won't always work:
124+
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:
125125

126126
<Sandpack>
127127

@@ -150,7 +150,7 @@ img { height: 90px; }
150150
151151
</Sandpack>
152152
153-
If you have existing HTML like this, you can fix it using a [converter](https://transform.tools/html-to-jsx):
153+
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):
154154
155155
<Sandpack>
156156
@@ -182,13 +182,13 @@ img { height: 90px; }
182182

183183
<LearnMore path="/learn/writing-markup-with-jsx">
184184

185-
Read **[Writing Markup with JSX](/learn/writing-markup-with-jsx)** to learn how to write valid JSX.
185+
Đọc **[Viết Markup với JSX](/learn/writing-markup-with-jsx)** để học cách viết JSX hợp lệ.
186186

187187
</LearnMore>
188188

189-
## JavaScript in JSX with curly braces {/*javascript-in-jsx-with-curly-braces*/}
189+
## JavaScript trong JSX với dấu ngoặc nhọn {/*javascript-in-jsx-with-curly-braces*/}
190190

191-
JSX lets you write HTML-like markup inside a JavaScript file, keeping rendering logic and content in the same place. Sometimes you will want to add a little JavaScript logic or reference a dynamic property inside that markup. In this situation, you can use curly braces in your JSX to "open a window" to JavaScript:
191+
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:
192192

193193
<Sandpack>
194194

@@ -230,13 +230,13 @@ body > div > div { padding: 20px; }
230230
231231
<LearnMore path="/learn/javascript-in-jsx-with-curly-braces">
232232
233-
Read **[JavaScript in JSX with Curly Braces](/learn/javascript-in-jsx-with-curly-braces)** to learn how to access JavaScript data from JSX.
233+
Đọc **[JavaScript trong JSX với Dấu Ngoặc Nhọn](/learn/javascript-in-jsx-with-curly-braces)** để học cách truy cập dữ liệu JavaScript từ JSX.
234234
235235
</LearnMore>
236236
237-
## Passing props to a component {/*passing-props-to-a-component*/}
237+
## Truyền props cho component {/*passing-props-to-a-component*/}
238238
239-
React components use *props* to communicate with each other. Every parent component can pass some information to its child components by giving them props. Props might remind you of HTML attributes, but you can pass any JavaScript value through them, including objects, arrays, functions, and even JSX!
239+
React component sử dụng *props* để giao tiếp với nhau. Mọi component cha có thể truyền một số thông tin cho component con của nó bằng cách cung cấp props cho chúng. Props có thể khiến bạn nhớ đến thuộc tính HTML, nhưng bạn có thể truyền bất kỳ giá trị JavaScript nào qua chúng, bao gồm object, array, function và thậm chí cả JSX!
240240
241241
<Sandpack>
242242
@@ -311,15 +311,15 @@ export function getImageUrl(person, size = 's') {
311311

312312
<LearnMore path="/learn/passing-props-to-a-component">
313313

314-
Read **[Passing Props to a Component](/learn/passing-props-to-a-component)** to learn how to pass and read props.
314+
Đọc **[Truyền Props cho Component](/learn/passing-props-to-a-component)** để học cách truyền và đọc props.
315315

316316
</LearnMore>
317317

318-
## Conditional rendering {/*conditional-rendering*/}
318+
## Render theo điều kiện {/*conditional-rendering*/}
319319

320-
Your components will often need to display different things depending on different conditions. In React, you can conditionally render JSX using JavaScript syntax like `if` statements, `&&`, and `? :` operators.
320+
Component của bạn thường sẽ cần hiển thị những thứ khác nhau tùy thuộc vào các điều kiện khác nhau. Trong React, bạn có thể render JSX theo điều kiện bằng cách sử dụng cú pháp JavaScript như câu lệnh `if`, toán tử `&&` `? :`.
321321

322-
In this example, the JavaScript `&&` operator is used to conditionally render a checkmark:
322+
Trong ví dụ này, toán tử `&&` JavaScript được sử dụng để render dấu kiểm theo điều kiện:
323323

324324
<Sandpack>
325325

@@ -359,15 +359,15 @@ export default function PackingList() {
359359
360360
<LearnMore path="/learn/conditional-rendering">
361361
362-
Read **[Conditional Rendering](/learn/conditional-rendering)** to learn the different ways to render content conditionally.
362+
Đọc **[Render Theo Điều Kiện](/learn/conditional-rendering)** để học các cách khác nhau để render nội dung theo điều kiện.
363363
364364
</LearnMore>
365365
366-
## Rendering lists {/*rendering-lists*/}
366+
## Render danh sách {/*rendering-lists*/}
367367
368-
You will often want to display multiple similar components from a collection of data. You can use JavaScript's `filter()` and `map()` with React to filter and transform your array of data into an array of components.
368+
Bạn sẽ thường muốn hiển thị nhiều component tương tự từ một tập hợp dữ liệu. Bạn có thể sử dụng `filter()` `map()` của JavaScript với React để lọc và chuyển đổi mảng dữ liệu của bạn thành mảng component.
369369
370-
For each array item, you will need to specify a `key`. Usually, you will want to use an ID from the database as a `key`. Keys let React keep track of each item's place in the list even if the list changes.
370+
Đối với mỗi item trong mảng, bạn sẽ cần chỉ định một `key`. Thông thường, bạn sẽ muốn sử dụng ID từ cơ sở dữ liệu làm `key`. Key cho phép React theo dõi vị trí của từng item trong danh sách ngay cả khi danh sách thay đổi.
371371
372372
<Sandpack>
373373
@@ -459,18 +459,18 @@ h2 { font-size: 20px; }
459459

460460
<LearnMore path="/learn/rendering-lists">
461461

462-
Read **[Rendering Lists](/learn/rendering-lists)** to learn how to render a list of components, and how to choose a key.
462+
Đọc **[Render Danh Sách](/learn/rendering-lists)** để học cách render danh sách component và cách chọn key.
463463

464464
</LearnMore>
465465

466-
## Keeping components pure {/*keeping-components-pure*/}
466+
## Giữ component thuần khiết {/*keeping-components-pure*/}
467467

468-
Some JavaScript functions are *pure.* A pure function:
468+
Một số JavaScript function là *thuần khiết.* Một function thuần khiết:
469469

470-
* **Minds its own business.** It does not change any objects or variables that existed before it was called.
471-
* **Same inputs, same output.** Given the same inputs, a pure function should always return the same result.
470+
* **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.
471+
* **Cùng đầu vào, cùng đầu ra.** Với cùng đầu vào, một function thuần khiết luôn trả về cùng kết quả.
472472

473-
By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs and unpredictable behavior as your codebase grows. Here is an example of an impure component:
473+
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:
474474

475475
<Sandpack>
476476

@@ -496,7 +496,7 @@ export default function TeaSet() {
496496

497497
</Sandpack>
498498

499-
You can make this component pure by passing a prop instead of modifying a preexisting variable:
499+
Bạn có thể làm cho component này thuần khiết bằng cách truyền prop thay vì thay đổi biến đã tồn tại trước:
500500

501501
<Sandpack>
502502

@@ -520,43 +520,43 @@ export default function TeaSet() {
520520

521521
<LearnMore path="/learn/keeping-components-pure">
522522

523-
Read **[Keeping Components Pure](/learn/keeping-components-pure)** to learn how to write components as pure, predictable functions.
523+
Đọ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.
524524

525525
</LearnMore>
526526

527-
## Your UI as a tree {/*your-ui-as-a-tree*/}
527+
## UI của bạn như một cây cấu trúc {/*your-ui-as-a-tree*/}
528528

529-
React uses trees to model the relationships between components and modules.
529+
React sử dụng cây để mô hình hóa các mối quan hệ giữa component và module.
530530

531-
A React render tree is a representation of the parent and child relationship between components.
531+
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.
532532

533533
<Diagram name="generic_render_tree" height={250} width={500} alt="A tree graph with five nodes, with each node representing a component. The root node is located at the top the tree graph and is labelled 'Root Component'. It has two arrows extending down to two nodes labelled 'Component A' and 'Component C'. Each of the arrows is labelled with 'renders'. 'Component A' has a single 'renders' arrow to a node labelled 'Component B'. 'Component C' has a single 'renders' arrow to a node labelled 'Component D'.">
534534

535-
An example React render tree.
535+
Một ví dụ về React render tree.
536536

537537
</Diagram>
538538

539-
Components near the top of the tree, near the root component, are considered top-level components. Components with no child components are leaf components. This categorization of components is useful for understanding data flow and rendering performance.
539+
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.
540540

541-
Modelling the relationship between JavaScript modules is another useful way to understand your app. We refer to it as a module dependency tree.
541+
Mô hình hóa mối quan hệ giữa các JavaScript module là một cách hữu ích khác để hiểu ứng dụng của bạn. Chúng ta gọi nó là module dependency tree.
542542

543-
<Diagram name="generic_dependency_tree" height={250} width={500} alt="A tree graph with five nodes. Each node represents a JavaScript module. The top-most node is labelled 'RootModule.js'. It has three arrows extending to the nodes: 'ModuleA.js', 'ModuleB.js', and 'ModuleC.js'. Each arrow is labelled as 'imports'. 'ModuleC.js' node has a single 'imports' arrow that points to a node labelled 'ModuleD.js'.">
543+
<Diagram name="generic_dependency_tree" height={250} width={500} alt="Một đồ thị cây với năm node. Mỗi node đại diện cho một JavaScript module. Node cao nhất được gắn nhãn 'RootModule.js'. Nó có ba mũi tên kéo dài đến các node: 'ModuleA.js', 'ModuleB.js', 'ModuleC.js'. Mỗi mũi tên được gắn nhãn 'imports'. Node 'ModuleC.js' có một mũi tên 'imports' duy nhất trỏ đến node được gắn nhãn 'ModuleD.js'.">
544544

545-
An example module dependency tree.
545+
Một ví dụ về module dependency tree.
546546

547547
</Diagram>
548548

549-
A dependency tree is often used by build tools to bundle all the relevant JavaScript code for the client to download and render. A large bundle size regresses user experience for React apps. Understanding the module dependency tree is helpful to debug such issues.
549+
Một dependency tree thường được sử dụng bởi các công cụ build để đóng gói tất cả code JavaScript liên quan cho client tải xuống và render. Kích thước bundle lớn làm giảm trải nghiệm người dùng cho ứng dụng React. Hiểu module dependency tree sẽ giúp debug những vấn đề như vậy.
550550

551551
<LearnMore path="/learn/understanding-your-ui-as-a-tree">
552552

553-
Read **[Your UI as a Tree](/learn/understanding-your-ui-as-a-tree)** to learn how to create a render and module dependency trees for a React app and how they're useful mental models for improving user experience and performance.
553+
Đọ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.
554554

555555
</LearnMore>
556556

557557

558-
## What's next? {/*whats-next*/}
558+
## Tiếp theo là gì? {/*whats-next*/}
559559

560-
Head over to [Your First Component](/learn/your-first-component) to start reading this chapter page by page!
560+
Hãy chuyển đến [Component Đầu Tiên Của Bạn](/learn/your-first-component) để bắt đầu đọc chương này từng trang một!
561561

562-
Or, if you're already familiar with these topics, why not read about [Adding Interactivity](/learn/adding-interactivity)?
562+
Hoặc, nếu bạn đã quen thuộc với những chủ đề này, tại sao không đọc về [Thêm Tương Tác](/learn/adding-interactivity)?

0 commit comments

Comments
 (0)