Composition vs Inheritance#12
Merged
vldmrkl merged 7 commits intoreactjs:masterfrom Feb 17, 2019
Merged
Conversation
Contributor
Author
|
Should be merged after #9. |
92 tasks
vldmrkl
requested changes
Feb 15, 2019
Member
vldmrkl
left a comment
There was a problem hiding this comment.
Дякую за переклад 😀
Лише декілька виправлень, а так виглядає дуже гарно. Можеш також будь-ласка прибрати handling-events.md з цього PR?
| ## Запобіжні заходи {#containment} | ||
|
|
||
| Some components don't know their children ahead of time. This is especially common for components like `Sidebar` or `Dialog` that represent generic "boxes". | ||
| Деякі компоненти не знають зарані про свої дочірні елементи. Це особливо характерно для таких компонентів як `Sidebar` чи `Dialog`, котрі представляють собою загальні контейнери. |
| **[Спробувати на CodePen](https://codepen.io/gaearon/pen/ozqNOV?editors=0010)** | ||
|
|
||
| Anything inside the `<FancyBorder>` JSX tag gets passed into the `FancyBorder` component as a `children` prop. Since `FancyBorder` renders `{props.children}` inside a `<div>`, the passed elements appear in the final output. | ||
| Усе, що знаходиться між JSX тегом `<FancyBorder>` буде передане в `FancyBorder` компонент як `children` проп. Оскільки `FancyBorder` рендерить `{props.children}` всередині `<div>`, передані елементи з'являться в фінальному виводі. |
Member
There was a problem hiding this comment.
у фінальному виводі замість в фінальному виводі
| Усе, що знаходиться між JSX тегом `<FancyBorder>` буде передане в `FancyBorder` компонент як `children` проп. Оскільки `FancyBorder` рендерить `{props.children}` всередині `<div>`, передані елементи з'являться в фінальному виводі. | ||
|
|
||
| While this is less common, sometimes you might need multiple "holes" in a component. In such cases you may come up with your own convention instead of using `children`: | ||
| Іноді, хоч і не так часто, вам може знадобитись кілька подібних "слотів" у компоненті. В таких випадках ви можети придумати власне рішення замість використання `children`: |
| ## То що з приводу наслідування? {#so-what-about-inheritance} | ||
|
|
||
| At Facebook, we use React in thousands of components, and we haven't found any use cases where we would recommend creating component inheritance hierarchies. | ||
| У Facebook ми використовуємо React в тисячах компонентів і ми не знайшли жодного випадку використання в якому б ми могли порадити створення ієрархій наслідування компонентів. |
Member
There was a problem hiding this comment.
у тисячах компонентів замість в тисячах компонентів
| Пропси і композиція дають вам всю необхідну гнучкість, щоб налаштувати вигляд і поведінку компонента в явний і безпечний спосіб. Пам'ятайте, що компоненти можуть приймати довільні пропси, включно з примітивами, React-елементами чи функціями. | ||
|
|
||
| If you want to reuse non-UI functionality between components, we suggest extracting it into a separate JavaScript module. The components may import it and use that function, object, or a class, without extending it. | ||
| Якщо ви хочете повторно використати функціональність котра не відноситься до інтерфейсу користувача, ми рекомендуємо виокремити її в окремий JavaScript модуль. Компоненти можуть імпортувати його і використувати функцію, об'єкт чи клас без наслідування. |
Member
There was a problem hiding this comment.
витягнути її в окремий замість виокреми її в окремий
ithompson4
reviewed
Feb 15, 2019
| Пропси і композиція дають вам всю необхідну гнучкість, щоб налаштувати вигляд і поведінку компонента в явний і безпечний спосіб. Пам'ятайте, що компоненти можуть приймати довільні пропси, включно з примітивами, React-елементами чи функціями. | ||
|
|
||
| If you want to reuse non-UI functionality between components, we suggest extracting it into a separate JavaScript module. The components may import it and use that function, object, or a class, without extending it. | ||
| Якщо ви хочете повторно використати функціональність котра не відноситься до інтерфейсу користувача, ми рекомендуємо витягнути її в окремий JavaScript модуль. Компоненти можуть імпортувати його і використувати функцію, об'єкт чи клас без наслідування. |
ithompson4
reviewed
Feb 15, 2019
| ## То що з приводу наслідування? {#so-what-about-inheritance} | ||
|
|
||
| At Facebook, we use React in thousands of components, and we haven't found any use cases where we would recommend creating component inheritance hierarchies. | ||
| У Facebook ми використовуємо React у тисячах компонентів і ми не знайшли жодного випадку використання в якому б ми могли порадити створення ієрархій наслідування компонентів. |
Collaborator
There was a problem hiding this comment.
missing comma , в якому or , у якому
vldmrkl
requested changes
Feb 16, 2019
| @@ -106,14 +106,14 @@ function WelcomeDialog() { | |||
| return ( | |||
| <Dialog | |||
| title="Welcome" | |||
vldmrkl
approved these changes
Feb 17, 2019
Member
|
@mihilbabin looks good, thank you for contribution :) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added translation for
Composition vs Inheritancesection.