Skip to content

Commit 5db2dff

Browse files
author
Gasim Gasimzada
authored
Merge pull request #91 from reactjs/translate-composition-vs-inheritance
Translate Composition vs Inheritance
2 parents 7126eb7 + 2fecfd7 commit 5db2dff

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

content/docs/composition-vs-inheritance.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
22
id: composition-vs-inheritance
3-
title: Composition vs Inheritance
3+
title: Kompozisiya vs Varislik
44
permalink: docs/composition-vs-inheritance.html
55
redirect_from:
66
- "docs/multiple-components.html"
77
prev: lifting-state-up.html
88
next: thinking-in-react.html
99
---
1010

11-
React has a powerful composition model, and we recommend using composition instead of inheritance to reuse code between components.
11+
React-in çox güclü kompozisiya modeli olduğundan komponentlər arasında kodu paylaşa bilmək üçün varislik əvəzinə kompozisiyadan istifadə etməyi tövsiyyə edirik.
1212

13-
In this section, we will consider a few problems where developers new to React often reach for inheritance, and show how we can solve them with composition.
13+
Bu bölmədə, React-ə yeni başlayan proqramçıların ilk yanaşmada varisliyə əl atdıqları problemləri nəzərə alıb, bu problemlərin kompozisiya ilə həllini göstərəcəyik.
1414

15-
## Containment {#containment}
15+
## Saxlama {#containment}
1616

17-
Some components don't know their children ahead of time. This is especially common for components like `Sidebar` or `Dialog` that represent generic "boxes".
17+
Bəzi komponentlərin əvvəlcədən uşaqları haqqında məlumatları yoxdur. Bu vəziyyət daha çox ümumi konteynerlər təsvir edən `Sidebar` və ya `Dialog` kimi komponentlərdə baş verir.
1818

19-
We recommend that such components use the special `children` prop to pass children elements directly into their output:
19+
Belə komponentlərin nəticəsinə uşaq komponentləri birbaşa göndərə bilmək üçün xüsusi `children` propundan istifadə etməyi tövsiyyə edirik:
2020

2121
```js{4}
2222
function FancyBorder(props) {
@@ -28,28 +28,28 @@ function FancyBorder(props) {
2828
}
2929
```
3030

31-
This lets other components pass arbitrary children to them by nesting the JSX:
31+
`children` propundan istifadə etdikdə uşaqları komponentlərə JSX təqinin içərisindən göndərə bilərsiniz:
3232

3333
```js{4-9}
3434
function WelcomeDialog() {
3535
return (
3636
<FancyBorder color="blue">
3737
<h1 className="Dialog-title">
38-
Welcome
38+
Xoş Gəlmisiniz
3939
</h1>
4040
<p className="Dialog-message">
41-
Thank you for visiting our spacecraft!
41+
Kosmik gəmimizi ziyarət etdiyiniz üçün təşəkkür edirik!
4242
</p>
4343
</FancyBorder>
4444
);
4545
}
4646
```
4747

48-
**[Try it on CodePen](https://codepen.io/gaearon/pen/ozqNOV?editors=0010)**
48+
**[CodePen-də sınayın](https://codepen.io/gaearon/pen/ozqNOV?editors=0010)**
4949

50-
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.
50+
`<FancyBorder>` JSX təqinin daxilində göndərilən bütün elementlər, `FancyBorder` komponentinin `children` propundan yerləşdirilir. `FancyBorder` `<div>`-də `{props.children}` render etdiyindən, göndərilən elementlər son nəticədə görünəcəklər.
5151

52-
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`:
52+
Daha az işlənməsinə baxmayaraq, bəzən komponentə bir neçə "render yeri" lazım ola bilər. Bu hallarda `children` əvəzinə öz yaratdığınız konvensiyadan istifadə edin:
5353

5454
```js{5,8,18,21}
5555
function SplitPane(props) {
@@ -78,15 +78,15 @@ function App() {
7878
}
7979
```
8080

81-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/gwZOJp?editors=0010)
81+
[**CodePen-də sınayın**](https://codepen.io/gaearon/pen/gwZOJp?editors=0010)
8282

83-
React elements like `<Contacts />` and `<Chat />` are just objects, so you can pass them as props like any other data. This approach may remind you of "slots" in other libraries but there are no limitations on what you can pass as props in React.
83+
`<Contacts />` `<Chat />` elementlərinin obyekt olduqlarından siz bu elementləri hər hansı bir məlumat kimi proplar ilə göndərə bilərsiniz. Bu yanaşma, başqa kitabxanalarda olan "yuvalar" (slots) konsepsiyasını yadınıza sala bilər. Lakin, React-də proplar ilə nələri göndərə biləcəyinizə heç bir məhdudiyyət yoxdur.
8484

85-
## Specialization {#specialization}
85+
## Xüsusiləşmə {#specialization}
8686

87-
Sometimes we think about components as being "special cases" of other components. For example, we might say that a `WelcomeDialog` is a special case of `Dialog`.
87+
Bəzən komponentlər digər kompontlərin "xüsusi halları" ola bilirlər. Məsələn, biz `WelcomeDialog` komponentinə `Dialog` komponentinin xüsusi halı kimi baxa bilərik.
8888

89-
In React, this is also achieved by composition, where a more "specific" component renders a more "generic" one and configures it with props:
89+
React-də bu yanaşma da kompozisiya ilə tətbiq edilir. "Xüsusi" komponentlər "ümumi" komponentləri fərqli proplar ilə render edirlər:
9090

9191
```js{5,8,16-18}
9292
function Dialog(props) {
@@ -105,15 +105,15 @@ function Dialog(props) {
105105
function WelcomeDialog() {
106106
return (
107107
<Dialog
108-
title="Welcome"
109-
message="Thank you for visiting our spacecraft!" />
108+
title="Xoş Gəlmisiniz"
109+
message="Kosmik gəmimizi ziyarət etdiyiniz üçün təşəkkür edirik!" />
110110
);
111111
}
112112
```
113113

114-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/kkEaOZ?editors=0010)
114+
[**CodePen-də sınayın**](https://codepen.io/gaearon/pen/kkEaOZ?editors=0010)
115115

116-
Composition works equally well for components defined as classes:
116+
Klas ilə müəyyənləşdirilmiş komponentlərdə belə kompozisiya yaxşı işləyir:
117117

118118
```js{10,27-31}
119119
function Dialog(props) {
@@ -140,12 +140,12 @@ class SignUpDialog extends React.Component {
140140
141141
render() {
142142
return (
143-
<Dialog title="Mars Exploration Program"
144-
message="How should we refer to you?">
143+
<Dialog title="Mars Kəşfiyyat Proqramı"
144+
message="Sizə müraciət edək?">
145145
<input value={this.state.login}
146146
onChange={this.handleChange} />
147147
<button onClick={this.handleSignUp}>
148-
Sign Me Up!
148+
Məni Qeydə Alın!
149149
</button>
150150
</Dialog>
151151
);
@@ -156,17 +156,17 @@ class SignUpDialog extends React.Component {
156156
}
157157
158158
handleSignUp() {
159-
alert(`Welcome aboard, ${this.state.login}!`);
159+
alert(`Salam ${this.state.login}!`);
160160
}
161161
}
162162
```
163163

164-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/gwZbYa?editors=0010)
164+
[**CodePen-də sınayın**](https://codepen.io/gaearon/pen/gwZbYa?editors=0010)
165165

166-
## So What About Inheritance? {#so-what-about-inheritance}
166+
## Bəs Varislik? {#so-what-about-inheritance}
167167

168-
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.
168+
Facebook-da, biz minlərlə komponent üçün React istifadə edirik və heç bir halda komponent varislik iyerarxiyası düzəltməyi tövsiyyə etmirik.
169169

170-
Props and composition give you all the flexibility you need to customize a component's look and behavior in an explicit and safe way. Remember that components may accept arbitrary props, including primitive values, React elements, or functions.
170+
Kompozisiya və proplar, komponentin görünüş və davranışını açıq və təhlükəsiz şəkildə özəlləşdirməyə imkan yaradır. Nəzərə alın ki, komponentlər primitiv dəyərləri, React elementləri, və ya funksiyaları proplar kimi qəbul edə bilirlər.
171171

172-
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.
172+
Əgər sizə bir neçə komponentəd işlətmək üçün UI olmayan funksionallıq lazımdırsa, biz bu funksionallığı ayrı JavaScript moduluna çıxarmağı tövsiyyə edirik. Komponentlər bu modulu idxal edib modulda olan funksiyanı, obyekti, və ya klası varislik lazım olmadan istifadə edə bilərlər.

0 commit comments

Comments
 (0)