-
Notifications
You must be signed in to change notification settings - Fork 125
Added translation for "React without JSX" section #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
--- | ||
id: react-without-jsx | ||
title: React Without JSX | ||
title: React без JSX | ||
permalink: docs/react-without-jsx.html | ||
--- | ||
|
||
JSX is not a requirement for using React. Using React without JSX is especially convenient when you don't want to set up compilation in your build environment. | ||
JSX не є вимогою для роботи з React. Використання React без JSX є найзручнішим тоді, коли ви не бажаєте налаштовувати компіляцію у вашому середовищі збірки. | ||
|
||
Each JSX element is just syntactic sugar for calling `React.createElement(component, props, ...children)`. So, anything you can do with JSX can also be done with just plain JavaScript. | ||
Кожен JSX-елемент являє собою "синтаксичний цукор" для виклику `React.createElement(component, props, ...children)`. Отже, все що можна зробити за допомогою JSX, може також бути виконаним на чистому JavaScript. | ||
|
||
For example, this code written with JSX: | ||
Наприклад, ось код на JSX: | ||
|
||
```js | ||
class Hello extends React.Component { | ||
render() { | ||
return <div>Hello {this.props.toWhat}</div>; | ||
return <div>Привіт, {this.props.toWhat}</div>; | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
<Hello toWhat="World" />, | ||
<Hello toWhat="світе" />, | ||
document.getElementById('root') | ||
); | ||
``` | ||
|
||
can be compiled to this code that does not use JSX: | ||
Його можна переписати таким чином, що JSX не буде використовуватися: | ||
|
||
```js | ||
class Hello extends React.Component { | ||
render() { | ||
return React.createElement('div', null, `Hello ${this.props.toWhat}`); | ||
return React.createElement('div', null, `Привіт, ${this.props.toWhat}`); | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
React.createElement(Hello, {toWhat: 'World'}, null), | ||
React.createElement(Hello, {toWhat: 'світе'}, null), | ||
document.getElementById('root') | ||
); | ||
Kurzdor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
If you're curious to see more examples of how JSX is converted to JavaScript, you can try out [the online Babel compiler](babel://jsx-simple-example). | ||
Якщо ви зацікавлені в інших прикладах того, як JSX компілюється в JavaScript-код, спробуйте [онлайн Babel-компілятор](babel://jsx-simple-example). | ||
|
||
The component can either be provided as a string, or as a subclass of `React.Component`, or a plain function for stateless components. | ||
Компонент може бути представлений у вигляді рядку, як підклас `React.Component` або у вигляді звичайної функції для компонентів без стану. | ||
|
||
If you get tired of typing `React.createElement` so much, one common pattern is to assign a shorthand: | ||
Якщо вас втомлює написання `React.createElement`, поширеною практикою є призначення "скорочення": | ||
|
||
```js | ||
const e = React.createElement; | ||
|
||
ReactDOM.render( | ||
e('div', null, 'Hello World'), | ||
e('div', null, 'Привіт, світе'), | ||
document.getElementById('root') | ||
); | ||
Kurzdor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
If you use this shorthand form for `React.createElement`, it can be almost as convenient to use React without JSX. | ||
Якщо ви використаєте дане скорочення для `React.createElement`, то робота з React без JSX буде такою ж зручною. | ||
Kurzdor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Alternatively, you can refer to community projects such as [`react-hyperscript`](https://github.com/mlmorg/react-hyperscript) and [`hyperscript-helpers`](https://github.com/ohanhi/hyperscript-helpers) which offer a terser syntax. | ||
Також ви можете ознайомитися з іншими проектами, як [`react-hyperscript`](https://github.com/mlmorg/react-hyperscript) і [`hyperscript-helpers`](https://github.com/ohanhi/hyperscript-helpers), які пропонують більш короткий синтаксис. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.