diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 3dcf2ac26..5c5080b10 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 を深く理解する 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: +JSX とは、つまるところ `React.createElement(component, props, ...children)` の糖衣構文にすぎません。例として、次の JSX コードを見てみましょう。 ```js @@ -21,7 +21,7 @@ Fundamentally, JSX just provides syntactic sugar for the `React.createElement(co ``` -compiles into: +これは以下のようにコンパイルされます。 ```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: +子要素を持たない場合には、自己クローズ (self-closing) タグを利用することもできます。次のコードを見てください。 ```js
``` -compiles into: +これは以下のようにコンパイルされます。 ```js React.createElement( @@ -47,19 +47,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). +具体的に JSX がどのように JavaScript へ変換されるのかをテストしたい場合は、[オンライン Babel コンパイラ](babel://jsx-simple-example)で試すことができます。 -## Specifying The React Element Type {#specifying-the-react-element-type} +## React 要素の型を指定する {#specifying-the-react-element-type} -The first part of a JSX tag determines the type of the React element. +JSX タグの先頭の部分は、React 要素の型を決定しています。 -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. +大文字で始まる型は JSX タグが React コンポーネントを参照していることを示しています。このような JSX タグはコンパイルを経てその大文字で始まる変数を直接参照するようになります。つまり JSX の `` 式を使用する場合、`Foo` がスコープになければなりません。 -### React Must Be in Scope {#react-must-be-in-scope} +### React がスコープ内にあること {#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. +JSX は `React.createElement` の呼び出しへとコンパイルされるため、`React` ライブラリは常に JSX コードのスコープ内にある必要があります。 -For example, both of the imports are necessary in this code, even though `React` and `CustomButton` are not directly referenced from JavaScript: +例えば以下のコードでは、`React` も `CustomButton` も JavaScript から直接は参照されていませんが、両方ともインポートされていることが必要です。 ```js{1,2,5} import React from 'react'; @@ -71,11 +71,11 @@ function WarningButton() { } ``` -If you don't use a JavaScript bundler and loaded React from a `