From a6e8933886b0710554298d4c5736da709161a9fb Mon Sep 17 00:00:00 2001 From: Renat Rysaev Date: Thu, 28 Feb 2019 00:22:02 +0500 Subject: [PATCH 1/6] Translate JSX In Depth. Draft. --- content/docs/jsx-in-depth.md | 156 ++++++++++++++++++----------------- content/docs/nav.yml | 2 +- 2 files changed, 80 insertions(+), 78 deletions(-) diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 3dcf2ac26..0cdddcdcf 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: +Вы также можете использовать самозакрывающийся тег, если отсутствуют дочерние элементы. Вот так: ```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 compiler](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 выражение `` , `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 `