From f4856c08af79ca78ac8cb6d2328f625e4b4e6918 Mon Sep 17 00:00:00 2001 From: To Manh Duc Date: Wed, 15 Sep 2021 22:16:52 +0700 Subject: [PATCH 1/2] translate jsx-in-depth part --- content/docs/jsx-in-depth.md | 145 +++++++++++++++++------------------ 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index c46a66246..d5fdc5654 100644 --- a/content/docs/jsx-in-depth.md +++ b/content/docs/jsx-in-depth.md @@ -1,6 +1,6 @@ --- id: jsx-in-depth -title: JSX In Depth +title: JSX Chuyên Sâu permalink: docs/jsx-in-depth.html redirect_from: - "docs/jsx-spread.html" @@ -13,7 +13,7 @@ redirect_from: - "docs/jsx-in-depth-ko-KR.html" --- -Fundamentally, JSX just provides syntactic sugar for the `React.createElement(component, props, ...children)` function. The JSX code: +Về cơ bản, JSX chỉ cung cấp cú pháp đặc biệt cho hàm `React.createElement(component, props, ...children)`. Đoạn mã JSX: ```js @@ -21,7 +21,7 @@ Fundamentally, JSX just provides syntactic sugar for the `React.createElement(co ``` -compiles into: +được biên dịch thành: ```js React.createElement( @@ -31,13 +31,13 @@ React.createElement( ) ``` -You can also use the self-closing form of the tag if there are no children. So: +Bạn cũng có thể sử dụng dạng thẻ tự đóng(self-closing) nếu không có children. Do vậy: ```js
``` -compiles into: +được biên dịch thành: ```js React.createElement( @@ -46,19 +46,19 @@ React.createElement( ) ``` -If you want to test out how some specific JSX is converted into JavaScript, you can try out [the online Babel compiler](babel://jsx-simple-example). +Nếu bạn muốn kiểm tra xem cách mà JSX được chuyển đổi sang JavaScript, bạn có thể thử [the online Babel compiler](babel://jsx-simple-example). -## Specifying The React Element Type {#specifying-the-react-element-type} +## Chỉ Định Kiểu React Element {#specifying-the-react-element-type} -The first part of a JSX tag determines the type of the React element. +Phần đầu tiên của một thẻ JSX xác định kiểu của React element. -Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the named variable, so if you use the JSX `` expression, `Foo` must be in scope. +Các kiểu viết hoa thể hiện rằng thẻ JSX đang ám chỉ tới một React component. Những thẻ này được biên dịch thành một tham chiếu trực tiếp đến biến được đặt tên, do vậy nếu bạn sử dụng biểu thức JSX ``, `Foo` phải nằm trong scope. -### React Must Be in Scope {#react-must-be-in-scope} +### React Phải Nằm trong Scope {#react-must-be-in-scope} -Since JSX compiles into calls to `React.createElement`, the `React` library must also always be in scope from your JSX code. +Vì JSX đuợc biên dịch thành lời gọi tới `React.createElement`, nên thư viện `React` phải luôn nằm trong scope mã JSX của bạn. -For example, both of the imports are necessary in this code, even though `React` and `CustomButton` are not directly referenced from JavaScript: +Ví dụ, cả hai import đều cần thiết trong đoạn mã này, mặc dù `React` và `CustomButton` không được tham chiếu trực tiếp từ JavaScript: ```js{1,2,5} import React from 'react'; @@ -70,11 +70,11 @@ function WarningButton() { } ``` -If you don't use a JavaScript bundler and loaded React from a `