Skip to content

Commit 7a063c6

Browse files
Vietnamese translation for React components and props documentation
1 parent e716782 commit 7a063c6

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

content/docs/components-and-props.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ Thông thường, các React apps mới tạo sẽ có một `App` component ở
124124

125125
## Tách Components {#extracting-components}
126126

127-
Don't be afraid to split components into smaller components.
127+
Đừng ngại ngần việc tách components thành các components nhỏ hơn.
128128

129-
For example, consider this `Comment` component:
129+
Ví dụ, cùng xem component `Comment` dưới đây:
130130

131131
```js
132132
function Comment(props) {
@@ -154,11 +154,11 @@ function Comment(props) {
154154

155155
[](codepen://components-and-props/extracting-components)
156156

157-
It accepts `author` (an object), `text` (a string), and `date` (a date) as props, and describes a comment on a social media website.
157+
Nó nhận `author` (một object), `text` (một sâu kí tự), `date` (ngày tháng) làm props, và mô phỏng lại một bình luận trên mạng xã hội.
158158

159-
This component can be tricky to change because of all the nesting, and it is also hard to reuse individual parts of it. Let's extract a few components from it.
159+
Component này có thể khó để thay đổi vì cấu trúc lồng nhau, đồng thời cũng khó có thể tái sử dụng lại các thành phần con bên trong nó. Hãy thử chia một vài components từ nó.
160160

161-
First, we will extract `Avatar`:
161+
Đầu tiên, chúng ta sẽ chia `Avatar`:
162162

163163
```js{3-6}
164164
function Avatar(props) {
@@ -171,11 +171,11 @@ function Avatar(props) {
171171
}
172172
```
173173

174-
The `Avatar` doesn't need to know that it is being rendered inside a `Comment`. This is why we have given its prop a more generic name: `user` rather than `author`.
174+
`Avatar` không cần phải biết nó đang được render bên trong `Comment`. Đây là lí do tại sao chúng ta truyền vào nó một prop với cái tên tổng quát là: `user` thay vì `author`.
175175

176-
We recommend naming props from the component's own point of view rather than the context in which it is being used.
176+
Chúng tôi khuyến khích việc đặt tên cho props dựa trên góc nhìn từ chính component hơn là ngữ cảnh mà component được sử dụng.
177177

178-
We can now simplify `Comment` a tiny bit:
178+
Chúng ta có thể đơn giản hoá `Comment` đi một chút:
179179

180180
```js{5}
181181
function Comment(props) {
@@ -198,7 +198,7 @@ function Comment(props) {
198198
}
199199
```
200200

201-
Next, we will extract a `UserInfo` component that renders an `Avatar` next to the user's name:
201+
Tiếp theo, chúng ta sẽ chia component `UserInfo`, component này sẽ render `Avatar` bên cạnh tên của user:
202202

203203
```js{3-8}
204204
function UserInfo(props) {
@@ -213,7 +213,7 @@ function UserInfo(props) {
213213
}
214214
```
215215

216-
This lets us simplify `Comment` even further:
216+
Điều này giúp chúng ta có thể đơn giản hoá `Comment` hơn nữa:
217217

218218
```js{4}
219219
function Comment(props) {
@@ -233,11 +233,11 @@ function Comment(props) {
233233

234234
[](codepen://components-and-props/extracting-components-continued)
235235

236-
Extracting components might seem like grunt work at first, but having a palette of reusable components pays off in larger apps. A good rule of thumb is that if a part of your UI is used several times (`Button`, `Panel`, `Avatar`), or is complex enough on its own (`App`, `FeedStory`, `Comment`), it is a good candidate to be extracted to a separate component.
236+
Chia các components ngay từ đầu là một công việc không đơn giản, nhưng bù lại chúng ta sẽ có được một tập hợp các components có thể tái sử dụng trong các ứng dụng lớn hơn khác. Một nguyên tắc quan trọng đó là nếu một phần UI của bạn được sử dụng lại nhiều lần (`Button`, `Panel`, `Avatar`), hoặc đủ phức tạp (`App`, `FeedStory`, `Comment`), thì đó là thời điểm thích hợp để chia chúng thành các component riêng.
237237

238-
## Props are Read-Only {#props-are-read-only}
238+
## Props chỉ dùng để đọc {#props-are-read-only}
239239

240-
Whether you declare a component [as a function or a class](#function-and-class-components), it must never modify its own props. Consider this `sum` function:
240+
Khi bạn định nghĩa một component [dưới dạng function hoặc class](#function-and-class-components), thì nó không được phép thay đổi props của chính nó. Hãy cùng phân tích hàm `sum` dưới đây:
241241

242242
```js
243243
function sum(a, b) {

0 commit comments

Comments
 (0)