Skip to content

Commit cd1a593

Browse files
authored
Merge pull request #22 from reactjs/alioguzhan/list-and-keys
Translate List and Keys
2 parents 0d1a1f5 + 5988e0c commit cd1a593

File tree

1 file changed

+47
-48
lines changed

1 file changed

+47
-48
lines changed

content/docs/lists-and-keys.md

+47-48
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
---
22
id: lists-and-keys
3-
title: Lists and Keys
3+
title: Listeler ve Anahtarlar
44
permalink: docs/lists-and-keys.html
55
prev: conditional-rendering.html
66
next: forms.html
77
---
88

9-
First, let's review how you transform lists in JavaScript.
9+
Öncelikle, listelerin JavaScript'te nasıl dönüştürüldüğünü gözden geçirelim.
1010

11-
Given the code below, we use the [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function to take an array of `numbers` and double their values. We assign the new array returned by `map()` to the variable `doubled` and log it:
11+
Aşağıdaki kod göz önüne alındığında, `sayılardan` oluşan bir diziyi almak ve değerlerini iki katına çıkarmak için [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) fonksiyonunu kullanırız. `map()` tarafından döndürülen yeni diziyi `doubled` değişkenine atayıp ekrana yazdırırız:
1212

1313
```javascript{2}
1414
const numbers = [1, 2, 3, 4, 5];
1515
const doubled = numbers.map((number) => number * 2);
1616
console.log(doubled);
1717
```
1818

19-
This code logs `[2, 4, 6, 8, 10]` to the console.
19+
Bu kod konsol ekranına `[2, 4, 6, 8, 10]` yazdırır.
2020

21-
In React, transforming arrays into lists of [elements](/docs/rendering-elements.html) is nearly identical.
21+
React'te, dizileri [öğe](/docs/rendering-elements.html) listelerine dönüştürmek de neredeyse aynıdır.
2222

23-
### Rendering Multiple Components {#rendering-multiple-components}
23+
### Çoklu Bileşenleri Render Etmek {#rendering-multiple-components}
2424

25-
You can build collections of elements and [include them in JSX](/docs/introducing-jsx.html#embedding-expressions-in-jsx) using curly braces `{}`.
25+
Öğelerden koleksiyonlar oluşturabilir ve bu koleksiyonları küme parentezlerini `{}` kullanarak [JSX'e dahil edebilirsiniz](/docs/introducing-jsx.html#embedding-expressions-in-jsx).
2626

27-
Below, we loop through the `numbers` array using the JavaScript [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function. We return a `<li>` element for each item. Finally, we assign the resulting array of elements to `listItems`:
27+
Aşağıda, Javascript'in [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) fonksiyonunu kullanarak `numbers` dizisinin içinde geziyoruz. Her bir öğe için bir `<li>` elemanı dönüyoruz. Son olarak da, ortaya çıkan diziyi `listItems` a atıyoruz:
2828

2929
```javascript{2-4}
3030
const numbers = [1, 2, 3, 4, 5];
@@ -33,7 +33,7 @@ const listItems = numbers.map((number) =>
3333
);
3434
```
3535

36-
We include the entire `listItems` array inside a `<ul>` element, and [render it to the DOM](/docs/rendering-elements.html#rendering-an-element-into-the-dom):
36+
`listItems` dizisinin tamamını bir `<ul>` elemanının içine ekliyoruz, ve [DOM'a render ediyoruz](/docs/rendering-elements.html#rendering-an-element-into-the-dom):
3737

3838
```javascript{2}
3939
ReactDOM.render(
@@ -42,15 +42,15 @@ ReactDOM.render(
4242
);
4343
```
4444

45-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/GjPyQr?editors=0011)
45+
[**CodePen'de deneyin**](https://codepen.io/gaearon/pen/GjPyQr?editors=0011)
4646

47-
This code displays a bullet list of numbers between 1 and 5.
47+
Bu kod, 1 ile 5 arasındaki sayıların madde işaretli listesini görüntüler.
4848

49-
### Basic List Component {#basic-list-component}
49+
### Temel Liste Bileşeni {#basic-list-component}
5050

51-
Usually you would render lists inside a [component](/docs/components-and-props.html).
51+
Genellikle listeleri bir [bileşenin](/docs/components-and-props.html) içinde render edersiniz.
5252

53-
We can refactor the previous example into a component that accepts an array of `numbers` and outputs a list of elements.
53+
Bir önceki örneği, bir `sayı` dizisini kabul eden ve bir öğe listesi çıktısı veren bir bileşende yeniden düzenleyebiliriz.
5454

5555
```javascript{3-5,7,13}
5656
function NumberList(props) {
@@ -70,9 +70,9 @@ ReactDOM.render(
7070
);
7171
```
7272

73-
When you run this code, you'll be given a warning that a key should be provided for list items. A "key" is a special string attribute you need to include when creating lists of elements. We'll discuss why it's important in the next section.
73+
Bu kodu çalıştırdığınızda, liste öğeleri için bir anahtar verilmesi gerektiği konusunda size bir uyarı verilir. Bir "anahtar", öğe listeleri oluştururken eklemeniz gereken özel bir string özelliğidir. Bunun neden önemli olduğunu bir sonraki bölümde tartışacağız.
7474

75-
Let's assign a `key` to our list items inside `numbers.map()` and fix the missing key issue.
75+
`numbers.map()` içindeki liste öğelerine birer `anahtar` atayalım ve eksik anahtar sorununu düzeltelim:
7676

7777
```javascript{4}
7878
function NumberList(props) {
@@ -94,11 +94,11 @@ ReactDOM.render(
9494
);
9595
```
9696

97-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/jrXYRR?editors=0011)
97+
[**CodePen'de deneyin**](https://codepen.io/gaearon/pen/jrXYRR?editors=0011)
9898

99-
## Keys {#keys}
99+
## Anahtarlar {#keys}
100100

101-
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity:
101+
Anahtarlar; hangi öğelerin değiştiğini, eklendiğini ya da silindiğini belirleme noktasında React'e yardımcı olur:
102102

103103
```js{3}
104104
const numbers = [1, 2, 3, 4, 5];
@@ -109,7 +109,7 @@ const listItems = numbers.map((number) =>
109109
);
110110
```
111111

112-
The best way to pick a key is to use a string that uniquely identifies a list item among its siblings. Most often you would use IDs from your data as keys:
112+
Bir anahtar seçmenin en iyi yolu, kardeşleri arasında bir liste öğesini benzersiz olarak tanımlayan bir string kullanmaktır. Çoğu zaman verinizin içindeki ID'leri anahtar olarak kullanırsınız:
113113

114114
```js{2}
115115
const todoItems = todos.map((todo) =>
@@ -119,34 +119,33 @@ const todoItems = todos.map((todo) =>
119119
);
120120
```
121121

122-
When you don't have stable IDs for rendered items, you may use the item index as a key as a last resort:
122+
Render edilen öğeleriniz için sabit ID'leriniz yoksa, son çare olarak, öğenin index numarasını anahtar olarak kullanabilirsiniz:
123123

124124
```js{2,3}
125125
const todoItems = todos.map((todo, index) =>
126-
// Only do this if items have no stable IDs
126+
// Bunu yalnızca öğelerinizin sabit ID'leri yoksa yapın
127127
<li key={index}>
128128
{todo.text}
129129
</li>
130130
);
131131
```
132+
Dizi içindeki elemanların değişme ihtimali varsa, anahtarlar için index numaralarının kullanılmasını önermiyoruz. Bu, performansı olumsuz yönde etkileyebilir ve bileşen state'i ile ilgili sorunlara neden olabilir. [Index numarasının anahtar olarak kullanılmasının olumsuz etkilerine dair detaylı açıklama](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318) için Robin Pokorny's makalesine göz atın. Öğeleri listelemek için belirgin bir anahtar atamamayı seçtiğinizde, React varsayılan olarak index numaralarını anahtar olarak kullanacaktır.
132133

133-
We don't recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state. Check out Robin Pokorny's article for an [in-depth explanation on the negative impacts of using an index as a key](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318). If you choose not to assign an explicit key to list items then React will default to using indexes as keys.
134+
Daha fazla bilgi edinmek istiyorsanız, işte size [neden anahtarların gerekli olduğuna dair](/docs/reconciliation.html#recursing-on-children) detaylı bir açıklama.
134135

135-
Here is an [in-depth explanation about why keys are necessary](/docs/reconciliation.html#recursing-on-children) if you're interested in learning more.
136+
### Anahtarları Olan Bileşenleri Çıkarmak {#extracting-components-with-keys}
136137

137-
### Extracting Components with Keys {#extracting-components-with-keys}
138+
Anahtarlar yalnızca çevreleyen dizinin bağlamında anlamlıdır.
138139

139-
Keys only make sense in the context of the surrounding array.
140+
Örneğin, bir `ListItem` bileşenini [çıkarırsanız](/docs/components-and-props.html#extracting-components), anahtarı `ListItem`'in içindeki `<li>` öğesinden ziyade, dizinin içindeki `<ListItem />` öğelerinde tutmalısınız.
140141

141-
For example, if you [extract](/docs/components-and-props.html#extracting-components) a `ListItem` component, you should keep the key on the `<ListItem />` elements in the array rather than on the `<li>` element in the `ListItem` itself.
142-
143-
**Example: Incorrect Key Usage**
142+
**Örenk: Yanlış Anahtar Kullanımı**
144143

145144
```javascript{4,5,14,15}
146145
function ListItem(props) {
147146
const value = props.value;
148147
return (
149-
// Wrong! There is no need to specify the key here:
148+
// Yanlış! Anahtarı burada belirtmeye gerek yok:
150149
<li key={value.toString()}>
151150
{value}
152151
</li>
@@ -156,7 +155,7 @@ function ListItem(props) {
156155
function NumberList(props) {
157156
const numbers = props.numbers;
158157
const listItems = numbers.map((number) =>
159-
// Wrong! The key should have been specified here:
158+
// Yanlış! Anahtar burada tanımlanmalıydı:
160159
<ListItem value={number} />
161160
);
162161
return (
@@ -173,18 +172,18 @@ ReactDOM.render(
173172
);
174173
```
175174

176-
**Example: Correct Key Usage**
175+
**Örnek: Doğru Anahtar Kullanımı**
177176

178177
```javascript{2,3,9,10}
179178
function ListItem(props) {
180-
// Correct! There is no need to specify the key here:
179+
// Doğru! Anahtarı burada belirtmeye gerek yok:
181180
return <li>{props.value}</li>;
182181
}
183182
184183
function NumberList(props) {
185184
const numbers = props.numbers;
186185
const listItems = numbers.map((number) =>
187-
// Correct! Key should be specified inside the array.
186+
// Doğru! Anahtar dizinin içinde belirtilmelidir:
188187
<ListItem key={number.toString()}
189188
value={number} />
190189
);
@@ -202,13 +201,13 @@ ReactDOM.render(
202201
);
203202
```
204203

205-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/ZXeOGM?editors=0010)
204+
[**CodePen'de deneyin**](https://codepen.io/gaearon/pen/ZXeOGM?editors=0010)
206205

207-
A good rule of thumb is that elements inside the `map()` call need keys.
206+
Temel bir kural da `map()` çağrısının içindeki elemanların anahtarlara ihtiyaç duymasıdır.
208207

209-
### Keys Must Only Be Unique Among Siblings {#keys-must-only-be-unique-among-siblings}
208+
### Anahtarlar Sadece Kardeşler Arasında Benzersiz Olmalıdır {#keys-must-only-be-unique-among-siblings}
210209

211-
Keys used within arrays should be unique among their siblings. However they don't need to be globally unique. We can use the same keys when we produce two different arrays:
210+
Dizilerde kullanılan anahtarlar kardeşleri arasında benzersiz olmalıdır. Ancak, küresel olarak benzersiz olmaları gerekmez. İki farklı dizi ürettiğimizde aynı anahtarları kullanabiliriz:
212211

213212
```js{2,5,11,12,19,21}
214213
function Blog(props) {
@@ -237,18 +236,18 @@ function Blog(props) {
237236
}
238237
239238
const posts = [
240-
{id: 1, title: 'Hello World', content: 'Welcome to learning React!'},
241-
{id: 2, title: 'Installation', content: 'You can install React from npm.'}
239+
{id: 1, title: 'Merhaba Dünya', content: 'React Öğrenmeye Hoşgeldiniz!'},
240+
{id: 2, title: 'Kurulum', content: 'React\'i npm üzerinden kurabilirsiniz.'}
242241
];
243242
ReactDOM.render(
244243
<Blog posts={posts} />,
245244
document.getElementById('root')
246245
);
247246
```
248247

249-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/NRZYGN?editors=0010)
248+
[**CodePen'de Deneyin**](https://codepen.io/gaearon/pen/NRZYGN?editors=0010)
250249

251-
Keys serve as a hint to React but they don't get passed to your components. If you need the same value in your component, pass it explicitly as a prop with a different name:
250+
Anahtarlar, React'e bir ipucu olarak hizmet eder, ancak bileşenlerinize aktarılmazlar. Bileşeninizde aynı değere ihtiyacınız varsa, belirgin bir şekilde farklı bir ada sahip bir `prop` olarak iletin:
252251

253252
```js{3,4}
254253
const content = posts.map((post) =>
@@ -259,11 +258,11 @@ const content = posts.map((post) =>
259258
);
260259
```
261260

262-
With the example above, the `Post` component can read `props.id`, but not `props.key`.
261+
Yukarıdaki örnekte, `Post` bileşeni `props.id` yi okuyabilir, ancak `props.key` i okuyamaz.
263262

264-
### Embedding map() in JSX {#embedding-map-in-jsx}
263+
### map() i JSX'e gömmek {#embedding-map-in-jsx}
265264

266-
In the examples above we declared a separate `listItems` variable and included it in JSX:
265+
Yukarıdaki örneklerde ayrı bir `listItems` değişkeni tanımladık ve JSX'e dahil ettik:
267266

268267
```js{3-6}
269268
function NumberList(props) {
@@ -280,7 +279,7 @@ function NumberList(props) {
280279
}
281280
```
282281

283-
JSX allows [embedding any expression](/docs/introducing-jsx.html#embedding-expressions-in-jsx) in curly braces so we could inline the `map()` result:
282+
JSX, [herhangi bir ifadeyi küme parantezlerine yerleştirmeye](/docs/introducing-jsx.html#embedding-expressions-in-jsx) izin verir, böylece `map ()` sonucunu satıriçi olarak ekleyebiliriz:
284283

285284
```js{5-8}
286285
function NumberList(props) {
@@ -296,6 +295,6 @@ function NumberList(props) {
296295
}
297296
```
298297

299-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/BLvYrB?editors=0010)
298+
[**CodePen'de Deneyin**](https://codepen.io/gaearon/pen/BLvYrB?editors=0010)
300299

301-
Sometimes this results in clearer code, but this style can also be abused. Like in JavaScript, it is up to you to decide whether it is worth extracting a variable for readability. Keep in mind that if the `map()` body is too nested, it might be a good time to [extract a component](/docs/components-and-props.html#extracting-components).
300+
Bazen bu yöntem daha temiz bir kodla sonuçlanır; ancak bu tarz da kötüye kullanılabilir. JavaScript'te olduğu gibi, okunabilirlik için, bir değişken çıkarmaya değip değmeyeceğine karar vermek size kalmıştır. `Map ()` gövdesi çok fazla iç içe geçmişse, [bir bileşen çıkarmak](/docs/components-and-props.html#extracting-components) için iyi bir zaman olabileceğini unutmayın.

0 commit comments

Comments
 (0)