Skip to content

Commit 6bda3ff

Browse files
Translated Components and Props
1 parent 6bd4173 commit 6bda3ff

File tree

1 file changed

+51
-45
lines changed

1 file changed

+51
-45
lines changed

content/docs/components-and-props.md

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: components-and-props
3-
title: Components and Props
3+
title: Bileşenler ve Prop'lar
44
permalink: docs/components-and-props.html
55
redirect_from:
66
- "docs/reusable-components.html"
@@ -16,23 +16,25 @@ prev: rendering-elements.html
1616
next: state-and-lifecycle.html
1717
---
1818

19-
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a [detailed component API reference here](/docs/react-component.html).
19+
Bileşenler, kullanıcı arayüzünü ayrıştırarak birbirinden bağımsız ve tekrar kullanılabilen parçalar oluşturmanızı sağlar. Bu sayede her bir parçayı birbirinden izole bir şekilde düşünerek kodlayabilirsiniz.
2020

21-
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen.
21+
Bu sayfa, bileşenlerin ne olduğuna dair bir fikir edinmenizi sağlayacaktır. [Bileşenler API dokümanını](/docs/react-component.html) inceleyerek daha detaylı bilgi edinebilirsiniz.
2222

23-
## Function and Class Components {#function-and-class-components}
23+
Kavramsal olarak bileşenler, JavaScript fonksiyonları gibidir. Bileşenler, "props" adındaki girdileri opsiyonel olarak alırlar ve ekranda görüntülenecek React elementlerini geri döndürürler.
2424

25-
The simplest way to define a component is to write a JavaScript function:
25+
## Fonksiyon ve Sınıf Bileşenleri {#function-and-class-components}
26+
27+
Bir bileşen oluşturmak için en basit yol, bir JavaScript fonksiyonu yazmaktır:
2628

2729
```js
2830
function Welcome(props) {
2931
return <h1>Hello, {props.name}</h1>;
3032
}
3133
```
3234

33-
This function is a valid React component because it accepts a single "props" (which stands for properties) object argument with data and returns a React element. We call such components "function components" because they are literally JavaScript functions.
35+
Bu fonksiyon, girdi olarak "props" (properties) adındaki tek bir nesneyi aldığı ve geriye bir React elementi döndürdüğü için geçerli bir React bileşenidir. Bu tarz bileşenler, gerçekten de birer JavaScript fonksiyonları oldukları için adına "fonksiyonel bileşenler" denir.
3436

35-
You can also use an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) to define a component:
37+
Fonksiyon yerine, bir [ES6 sınıfı](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) kullanarak da React bileşeni oluşturabilirsiniz:
3638

3739
```js
3840
class Welcome extends React.Component {
@@ -42,27 +44,27 @@ class Welcome extends React.Component {
4244
}
4345
```
4446

45-
The above two components are equivalent from React's point of view.
47+
Üstteki her iki bileşen de React'in bakış açısından birbirine eşittirler.
4648

47-
Classes have some additional features that we will discuss in the [next sections](/docs/state-and-lifecycle.html). Until then, we will use function components for their conciseness.
49+
Sınıf bileşenleri, fonksiyon bileşenlerine göre bazı ek özelliklere sahiptirler. Buna [sonraki bölümlerde](/docs/state-and-lifecycle.html) değineceğiz. Fakat şimdilik, kısa olması açısından fonksiyon bileşenleri kullanacağız.
4850

49-
## Rendering a Component {#rendering-a-component}
51+
## Bir Bileşenin Render Edilmesi {#rendering-a-component}
5052

51-
Previously, we only encountered React elements that represent DOM tags:
53+
Önceki bölümlerde, React elementi olarak sadece DOM elementlerini ele almıştık.
5254

5355
```js
5456
const element = <div />;
5557
```
5658

57-
However, elements can also represent user-defined components:
59+
Ancak elementler, kullanıcı tanımlı bileşenler de olabilirler:
5860

5961
```js
6062
const element = <Welcome name="Sara" />;
6163
```
6264

63-
When React sees an element representing a user-defined component, it passes JSX attributes to this component as a single object. We call this object "props".
65+
React, kullanıcı tanımlı bir bileşeni gördüğü zaman, bünyesinde yer alan JSX özelliklerini bu bileşene tek bir nesne olarak aktarır. Bu nesneye "props" adı verilir.
6466

65-
For example, this code renders "Hello, Sara" on the page:
67+
Örneğin aşağıdaki kod, sayfada "Hello, Sara" mesajını görüntüler:
6668

6769
```js{1,5}
6870
function Welcome(props) {
@@ -78,24 +80,24 @@ ReactDOM.render(
7880

7981
[](codepen://components-and-props/rendering-a-component)
8082

81-
Let's recap what happens in this example:
83+
Bu örnekte, hangi olayların gerçekleştiğine bir bakalım:
8284

83-
1. We call `ReactDOM.render()` with the `<Welcome name="Sara" />` element.
84-
2. React calls the `Welcome` component with `{name: 'Sara'}` as the props.
85-
3. Our `Welcome` component returns a `<h1>Hello, Sara</h1>` element as the result.
86-
4. React DOM efficiently updates the DOM to match `<h1>Hello, Sara</h1>`.
85+
1. `<Welcome name="Sara" />` elementi ile birlikte `ReactDOM.render()` fonksiyonunu çağırıyoruz.
86+
2. Devamında React, `{name: 'Sara'}` prop'u ile `Welcome` bileşenini çağırıyor.
87+
3. `Welcome` bileşenimiz, sonuç olarak geriye bir `<h1>Hello, Sara</h1>` elementi döndürüyor.
88+
4. React DOM, `<h1>Hello, Sara</h1>` ile eşleşmek için, DOM'u arka planda efektif bir şekilde güncelliyor .
8789

88-
>**Note:** Always start component names with a capital letter.
90+
>**Not:** Bileşen isimlendirmelerinde daima büyük harfle başlayınız.
8991
>
90-
>React treats components starting with lowercase letters as DOM tags. For example, `<div />` represents an HTML div tag, but `<Welcome />` represents a component and requires `Welcome` to be in scope.
92+
>Çünkü React, küçük harfle başlayan bileşenlere DOM etiketleri gibi davranır. Örneğin `<div />`, bir HTML div etiketini temsil eder, fakat `<Welcome />` ise bir bileşeni temsil eder ve kodun etki alanında `Welcome`'ın tanımlı olmasını gerektirir.
9193
>
92-
>To learn more about the reasoning behind this convention, please read [JSX In Depth](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized).
94+
>Bu isimlendirmenin nedeni hakkında detaylı bilgi edinmek için lütfen [Derinlemesine JSX](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized) sayfasına bakınız.
9395
94-
## Composing Components {#composing-components}
96+
## Bileşenlerden Kompozisyon Oluşturulması {#composing-components}
9597

96-
Components can refer to other components in their output. This lets us use the same component abstraction for any level of detail. A button, a form, a dialog, a screen: in React apps, all those are commonly expressed as components.
98+
Bileşenler, çıktılarında diğer bileşenleri gösterebilir. Bu sayede soyutlanan bir bileşen, herhangi bir ayrıntı düzeyinde tekrar kullanılabilir. Butonlar, formlar, diyaloglar, ekranlar ve daha nicesi React uygulamalarında yaygın bir şekilde bileşen olarak ifade edilebilirler.
9799

98-
For example, we can create an `App` component that renders `Welcome` many times:
100+
Örneğin, `Welcome`'ı istediğimiz kadar görüntüleyecek bir `App` bileşeni oluşturabiliriz:
99101

100102
```js{8-10}
101103
function Welcome(props) {
@@ -120,13 +122,13 @@ ReactDOM.render(
120122

121123
[](codepen://components-and-props/composing-components)
122124

123-
Typically, new React apps have a single `App` component at the very top. However, if you integrate React into an existing app, you might start bottom-up with a small component like `Button` and gradually work your way to the top of the view hierarchy.
125+
Genellikle, yeni React uygulamaları, en üstte bir tane `App` bileşeni içerirler. Ancak React'i mevcut uygulamanıza entegre ediyorsanız, `Button` gibi en küçük bileşenlerden başlayacak şekilde basitten karmaşığa doğru ilerleyerek bileşen hiyerarşisini oluşturabilirsiniz.
124126

125-
## Extracting Components {#extracting-components}
127+
## Bileşenlerin Çıkarılması {#extracting-components}
126128

127-
Don't be afraid to split components into smaller components.
129+
Büyük bileşenleri, sade ve yönetilebilir olması açısından daha küçük bileşenlere bölebilirsiniz.
128130

129-
For example, consider this `Comment` component:
131+
Örneğin aşağıdaki `Comment` bileşenini ele alalım:
130132

131133
```js
132134
function Comment(props) {
@@ -154,11 +156,11 @@ function Comment(props) {
154156

155157
[](codepen://components-and-props/extracting-components)
156158

157-
It accepts `author` (an object), `text` (a string), and `date` (a date) as props, and describes a comment on a social media website.
159+
Üstteki bileşen; `author` nesnesini, `text` metnini, ve bir `date` tarihini prop olarak alır. Bu bileşen, bir sosyal medya sitesinde yorum kutucuğunun görüntülenmesini sağlar.
158160

159-
This component can be tricky to change because of all the nesting, and it is also hard to reuse individual parts of it. Let's extract a few components from it.
161+
İç içe halde bulunan bu bileşenin üzerinde değişiklik yapmak zor olabilir. Ayrıca bünyesindeki DOM elementlerinin de tekrar kullanılabilirliği oldukça düşük seviyede. Bu durumu çözmek için, kod içerisinden birkaç bileşen çıkarabiliriz.
160162

161-
First, we will extract `Avatar`:
163+
Öncelikle `Avatar` bileşenini çıkaralım:
162164

163165
```js{3-6}
164166
function Avatar(props) {
@@ -171,11 +173,11 @@ function Avatar(props) {
171173
}
172174
```
173175

174-
The `Avatar` doesn't need to know that it is being rendered inside a `Comment`. This is why we have given its prop a more generic name: `user` rather than `author`.
176+
`Avatar` bileşeninin, bir `Comment` bileşeni içerisinde render edildiğini bilmesi gerekli değildir. Bu nedenle `Avatar` bileşenini, gelecekte uygulamanın daha farklı yerlerinde de kullanma ihtimalimiz bulunduğundan dolayı, prop değişkenleri için `author` yerine `user` gibi daha genel bir isim verebiliriz.
175177

176-
We recommend naming props from the component's own point of view rather than the context in which it is being used.
178+
Prop'lar isimlendirilirken, ilgili bileşenin hangi bileşen içerisinde kullanıldığını ele almak yerine, bileşeni bağımsız olarak ele almanız gerekmektedir.
177179

178-
We can now simplify `Comment` a tiny bit:
180+
Yaptığımız değişiklikle `Comment` bileşenini az bir miktar basitleştirmiş olduk:
179181

180182
```js{5}
181183
function Comment(props) {
@@ -198,7 +200,7 @@ function Comment(props) {
198200
}
199201
```
200202

201-
Next, we will extract a `UserInfo` component that renders an `Avatar` next to the user's name:
203+
Şimdi `Avatar` ile birlikte, kullanıcı adını da render edecek olan `UserInfo` bileşenini kod içerisinden çıkarabiliriz.
202204

203205
```js{3-8}
204206
function UserInfo(props) {
@@ -213,7 +215,7 @@ function UserInfo(props) {
213215
}
214216
```
215217

216-
This lets us simplify `Comment` even further:
218+
Bu sayede `Comment` bileşeni daha da basitleşmiş hale geldi:
217219

218220
```js{4}
219221
function Comment(props) {
@@ -233,30 +235,34 @@ function Comment(props) {
233235

234236
[](codepen://components-and-props/extracting-components-continued)
235237

236-
Extracting components might seem like grunt work at first, but having a palette of reusable components pays off in larger apps. A good rule of thumb is that if a part of your UI is used several times (`Button`, `Panel`, `Avatar`), or is complex enough on its own (`App`, `FeedStory`, `Comment`), it is a good candidate to be a reusable component.
238+
Bileşenlerin çıkarılması en başta angarya bir işlem gibi görünebilir. Fakat büyük çaplı uygulamalarda, tekrar kullanılabilir bileşenler içeren bir **bileşen paletine** sahip olmak oldukça faydalı hale gelecektir. Bileşen çıkarmanın genel mantığı aşağıdaki gibidir:
239+
* Eğer kullanıcı arayüzündeki bir eleman (`Button`, `Panel`, `Avatar`) uygulama içerisinde birçok defa kullanılıyorsa,
240+
* Eğer bir bileşen (`App`, `FeedStory`, `Comment`) oldukça karmaşık hale geldiyse,
241+
242+
bu bileşen, içerisinden bileşenler çıkarmak için iyi bir adaydır diyebiliriz.
237243

238-
## Props are Read-Only {#props-are-read-only}
244+
## Prop'lar ve Salt Okunurlar {#props-are-read-only}
239245

240-
Whether you declare a component [as a function or a class](#function-and-class-components), it must never modify its own props. Consider this `sum` function:
246+
[Fonksiyon veya sınıf](#function-and-class-components) bileşeninden herhangi birini oluşturduğunuzda, bu bileşen kendi prop'larını asla değiştirmemelidir. Örneğin aşağıdaki `sum` fonksiyonunu ele alalım:
241247

242248
```js
243249
function sum(a, b) {
244250
return a + b;
245251
}
246252
```
247253

248-
Such functions are called ["pure"](https://en.wikipedia.org/wiki/Pure_function) because they do not attempt to change their inputs, and always return the same result for the same inputs.
254+
Bu tarz fonksiyonlar, kendi girdi parametrelerini değiştirmedikleri ve her zaman aynı parametreler için aynı sonucu ürettiklerinden dolayı ["pure"](https://en.wikipedia.org/wiki/Pure_function) (saf) fonksiyonlardır.
249255

250-
In contrast, this function is impure because it changes its own input:
256+
Tam ters örnek verecek olursak, aşağıdaki fonksiyon impure'dür (saf değildir). Çünkü kendi girdi değerini değiştirmektedir:
251257

252258
```js
253259
function withdraw(account, amount) {
254260
account.total -= amount;
255261
}
256262
```
257263

258-
React is pretty flexible but it has a single strict rule:
264+
React, kod yazımında oldukça esnek olmasına rağmen, sadece bir tek kuralı şart koşmaktadır:
259265

260-
**All React components must act like pure functions with respect to their props.**
266+
**Bütün React bileşenleri pure fonksiyonlar gibi davranmalı, ve prop'larını asla değiştirmemelidirler.**
261267

262-
Of course, application UIs are dynamic and change over time. In the [next section](/docs/state-and-lifecycle.html), we will introduce a new concept of "state". State allows React components to change their output over time in response to user actions, network responses, and anything else, without violating this rule.
268+
Tabi ki kullanıcı arayüzleri dinamiktir ve zaman içerisinde değişiklik gösterir. [Sonraki bölümde](/docs/state-and-lifecycle.html), "state" (durum) adındaki yeni konsepte değineceğiz. State bu kurala sadık kalarak; kullanıcı etkileşimleri, ağ istekleri ve diğer şeylerden dolayı zaman içerisinde değişen arayüzün görüntülenmesi için, React bileşenlerinin kendi çıktılarını değiştirebilmesine izin verir.

0 commit comments

Comments
 (0)