Skip to content

Commit a0b2560

Browse files
committed
translate until challenges rendering-lists
1 parent decfc54 commit a0b2560

File tree

1 file changed

+62
-60
lines changed

1 file changed

+62
-60
lines changed

src/content/learn/rendering-lists.md

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: Rendering Lists
2+
title: Listeleri Render Etmek
33
---
44

55
<Intro>
66

7-
You will often want to display multiple similar components from a collection of data. You can use the [JavaScript array methods](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#) to manipulate an array of data. On this page, you'll use [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) and [`map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map) with React to filter and transform your array of data into an array of components.
7+
Genellikle bir veri topluluğundan birden fazla bileşen göstermek isteyeceksiniz. Bir veri dizisini manipule etmek için [JavaScript dizi metodlarını](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#) kullanabilirsiniz. Bu sayfada, React ile [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) ve [`map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map) metodlarını kullanarak bir veri dizisini filtreleyecek ve bir bileşen dizisine dönüştüreceksiniz.
88

99
</Intro>
1010

1111
<YouWillLearn>
1212

13-
* How to render components from an array using JavaScript's `map()`
14-
* How to render only specific components using JavaScript's `filter()`
15-
* When and why to use React keys
13+
* Javascript'in `map()` metodunu kullanarak bir diziden nasıl bileşenler oluşturulur?
14+
* Javascript'in `filter()` metodunu kullanarak yalnızca belirli bileşenler nasıl oluşturulur?
15+
* React anahtarlarını ne zaman ve neden kullanmalı?
1616

1717
</YouWillLearn>
1818

19-
## Rendering data from arrays {/*rendering-data-from-arrays*/}
19+
## Dizilerden veri render etmek {/*rendering-data-from-arrays*/}
2020

21-
Say that you have a list of content.
21+
Aşağıdaki gibi bir içerik listeniz olduğunu düşünelim.
2222

2323
```js
2424
<ul>
@@ -30,11 +30,12 @@ Say that you have a list of content.
3030
</ul>
3131
```
3232

33-
The only difference among those list items is their contents, their data. You will often need to show several instances of the same component using different data when building interfaces: from lists of comments to galleries of profile images. In these situations, you can store that data in JavaScript objects and arrays and use methods like [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) and [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) to render lists of components from them.
33+
Bu liste öğeleri arasındaki tek fark içerikleri, verileridir. Arayüzler oluştururken farklı veriler kullanan aynı bileşenin birkaç örneğini göstermeniz gerekebilir: yorum listelerinden profil resimleri galerilerine kadar. Bu gibi durumlarda, gerekli verileri Javascript objeleri ve dizilerinde saklayabilir ve [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) ve [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) gibi metodları kullanarak bu verilerden bileşen listeleri oluşturabilirsiniz.
3434

35-
Here’s a short example of how to generate a list of items from an array:
35+
Aşağıdaki kısa örnekte bir diziden nasıl öğe listesi oluşturulduğunu görebilirsiniz.
3636

37-
1. **Move** the data into an array:
37+
38+
1. **Aktar** veriyi bir dizi içine:
3839

3940
```js
4041
const people = [
@@ -46,19 +47,19 @@ const people = [
4647
];
4748
```
4849

49-
2. **Map** the `people` members into a new array of JSX nodes, `listItems`:
50+
2. **Map** metodu ile `people` üyelerini `listItems` adında yeni bir JSX node dizisiyle eşleştirin:
5051

5152
```js
5253
const listItems = people.map(person => <li>{person}</li>);
5354
```
5455

55-
3. **Return** `listItems` from your component wrapped in a `<ul>`:
56+
3. **Döndür** `<ul>` ile sarılmış bileşeninizden `listItems`:
5657

5758
```js
5859
return <ul>{listItems}</ul>;
5960
```
6061

61-
Here is the result:
62+
İşte sonuç:
6263

6364
<Sandpack>
6465

@@ -85,19 +86,19 @@ li { margin-bottom: 10px; }
8586

8687
</Sandpack>
8788

88-
Notice the sandbox above displays a console error:
89+
Yukarıdaki sandbox'un bir konsol hatası gösterdiğine dikkat edin:
8990

9091
<ConsoleBlock level="error">
9192

92-
Warning: Each child in a list should have a unique "key" prop.
93+
Uyarı: Bir listedeki her alt elemanın benzersiz bir "anahtar" prop'u olmalıdır.
9394

9495
</ConsoleBlock>
9596

96-
You'll learn how to fix this error later on this page. Before we get to that, let's add some structure to your data.
97+
Bu hatayı daha sonra bu sayfada nasıl düzelteceğinizi öğreneceksiniz. Buna gelmeden önce, verilerinize biraz yapı ekleyelim.
9798

98-
## Filtering arrays of items {/*filtering-arrays-of-items*/}
99+
## Öğe dizilerini filtreleme {/*filtering-arrays-of-items*/}
99100

100-
This data can be structured even more.
101+
Bu veriler daha da yapılandırılabilir.
101102

102103
```js
103104
const people = [{
@@ -121,19 +122,19 @@ const people = [{
121122
}];
122123
```
123124

124-
Let's say you want a way to only show people whose profession is `'chemist'`. You can use JavaScript's `filter()` method to return just those people. This method takes an array of items, passes them through a “test” (a function that returns `true` or `false`), and returns a new array of only those items that passed the test (returned `true`).
125+
Diyelim ki sadece mesleği `'chemist'` olan kişileri göstermenin bir yolunu istiyorsunuz. Javacript'in `filter()` metodunu kullanarak yalnızca bu kişileri döndürebilirsiniz. Bu yöntem, bir öğe dizisini alır, onları bir "testten" (`doğru` veya `yanlış` döndüren bir test) geçirir ve yalnızca testi geçen (`doğru` olarak döndürülen) öğelerden oluşan yeni bir dizi döndürür.
125126

126-
You only want the items where `profession` is `'chemist'`. The "test" function for this looks like `(person) => person.profession === 'chemist'`. Here's how to put it together:
127+
Sadece mesleği `'chemist'` olan kişileri istiyorsunuz. Bunun için "test" fonksiyonu `(person) => person.profession === 'chemist'` şeklindedir. Bunu nasıl bir araya getireceğiniz aşağıda gösterilmiştir:
127128

128-
1. **Create** a new array of just “chemist” people, `chemists`, by calling `filter()` on the `people` filtering by `person.profession === 'chemist'`:
129+
1. Sadece "kimyacı" mesleğindeki insanlardan yeni bir `chemists` dizisi **oluştur**, bunun için `filter()` metodu `people` dizisinde `person.profession === 'chemist'` şeklinde kullanılır:
129130

130131
```js
131132
const chemists = people.filter(person =>
132133
person.profession === 'chemist'
133134
);
134135
```
135136

136-
2. Now **map** over `chemists`:
137+
2. Şimdi `chemists` dizisinde **map** metodu kullanılır:
137138

138139
```js {1,13}
139140
const listItems = chemists.map(person =>
@@ -151,7 +152,7 @@ const listItems = chemists.map(person =>
151152
);
152153
```
153154

154-
3. Lastly, **return** the `listItems` from your component:
155+
3. Son olarak, bileşeninizden `listItems` **döndürülür**:
155156

156157
```js
157158
return <ul>{listItems}</ul>;
@@ -244,51 +245,52 @@ img { width: 100px; height: 100px; border-radius: 50%; }
244245

245246
<Pitfall>
246247

247-
Arrow functions implicitly return the expression right after `=>`, so you didn't need a `return` statement:
248+
Ok fonksiyonları, "=>" ifadesinden hemen sonra ifadeyi hemen döndürür, böyle bir `return` ifadesine ihtiyacınız olmaz:
249+
248250

249251
```js
250252
const listItems = chemists.map(person =>
251253
<li>...</li> // Implicit return!
252254
);
253255
```
254256

255-
However, **you must write `return` explicitly if your `=>` is followed by a `{` curly brace!**
257+
Ancak, **`=>` ifadesinden sonra `{` parentezi kullandıysanız, `return` ifadesini yazmak zorundasınız**
256258

257259
```js
258260
const listItems = chemists.map(person => { // Curly brace
259261
return <li>...</li>;
260262
});
261263
```
262264

263-
Arrow functions containing `=> {` are said to have a ["block body".](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body) They let you write more than a single line of code, but you *have to* write a `return` statement yourself. If you forget it, nothing gets returned!
265+
`=> {` içeren ok fonksiyonların bir ["blok gövdesi".](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body) olduğu söylenir. Ok fonksiyonları tek bir kod satırından daha fazlasını yazmanıza olanak verir ancak `return` ifadesini yazmanız gerekmektedir. Eğer unutursanız, fonksiyonunuz geri hiçbir şey döndürmez!
264266

265267
</Pitfall>
266268

267-
## Keeping list items in order with `key` {/*keeping-list-items-in-order-with-key*/}
269+
## `anahtar` ile liste öğelerini sıralı tutmak {/*keeping-list-items-in-order-with-key*/}
268270

269-
Notice that all the sandboxes above show an error in the console:
271+
Yukarıdaki tüm sandboxların konsolda bir hata gösterdiğine dikkat edin:
270272

271273
<ConsoleBlock level="error">
272274

273-
Warning: Each child in a list should have a unique "key" prop.
275+
Uyarı: Bir listedeki her alt elemanın benzersiz bir "anahtar" prop'u olmalıdır.
274276

275277
</ConsoleBlock>
276278

277-
You need to give each array item a `key` -- a string or a number that uniquely identifies it among other items in that array:
279+
Herbir dizi öğesine bir `anahtar` vermelisiniz -- dizideki herbir öğeyi birbirinden ayırt edecek şekilde o öğeye bir string ya da numara vermeniz gerekmektedir:
278280

279281
```js
280282
<li key={person.id}>...</li>
281283
```
282284

283285
<Note>
284286

285-
JSX elements directly inside a `map()` call always need keys!
287+
Her `map()` metodu kullanıldığında JSX elementleri bir anahtara ihtiyaç duyar.
286288

287289
</Note>
288290

289-
Keys tell React which array item each component corresponds to, so that it can match them up later. This becomes important if your array items can move (e.g. due to sorting), get inserted, or get deleted. A well-chosen `key` helps React infer what exactly has happened, and make the correct updates to the DOM tree.
291+
Anahtarlar, React'e her bir bileşenin hangi dizi öğesine karşılık geldiğini söylerek React'in daha sonra bu öğeleri eşleştirmesini sağlar. Bu durum, eğer dizi öğeleriniz yer değiştiriyorsa (örneğin sıralaması değişiyorsa), yeni öğeler eklenip veya çıkartılabiliyorsa daha önemli bir hale gelir. İyi seçilmiş bir `anahtar` React'in değişen öğelerde ne olduğunu anlamasına ve DOM ağacında doğru güncellemeleri yapmasına yardımcı olur.
290292

291-
Rather than generating keys on the fly, you should include them in your data:
293+
Anında anahtar oluşturmak yerine, anahtarları verilerinize dahil etmelisiniz:
292294

293295
<Sandpack>
294296

@@ -316,31 +318,31 @@ export default function List() {
316318

317319
```js data.js active
318320
export const people = [{
319-
id: 0, // Used in JSX as a key
321+
id: 0, // JSX için anahtar olarak kullanılır
320322
name: 'Creola Katherine Johnson',
321323
profession: 'mathematician',
322324
accomplishment: 'spaceflight calculations',
323325
imageId: 'MK3eW3A'
324326
}, {
325-
id: 1, // Used in JSX as a key
327+
id: 1, // JSX için anahtar olarak kullanılır
326328
name: 'Mario José Molina-Pasquel Henríquez',
327329
profession: 'chemist',
328330
accomplishment: 'discovery of Arctic ozone hole',
329331
imageId: 'mynHUSa'
330332
}, {
331-
id: 2, // Used in JSX as a key
333+
id: 2, // JSX için anahtar olarak kullanılır
332334
name: 'Mohammad Abdus Salam',
333335
profession: 'physicist',
334336
accomplishment: 'electromagnetism theory',
335337
imageId: 'bE7W1ji'
336338
}, {
337-
id: 3, // Used in JSX as a key
339+
id: 3, // JSX için anahtar olarak kullanılır
338340
name: 'Percy Lavon Julian',
339341
profession: 'chemist',
340342
accomplishment: 'pioneering cortisone drugs, steroids and birth control pills',
341343
imageId: 'IOjWm71'
342344
}, {
343-
id: 4, // Used in JSX as a key
345+
id: 4, // JSX için anahtar olarak kullanılır
344346
name: 'Subrahmanyan Chandrasekhar',
345347
profession: 'astrophysicist',
346348
accomplishment: 'white dwarf star mass calculations',
@@ -374,11 +376,11 @@ img { width: 100px; height: 100px; border-radius: 50%; }
374376

375377
<DeepDive>
376378

377-
#### Displaying several DOM nodes for each list item {/*displaying-several-dom-nodes-for-each-list-item*/}
379+
#### Her liste öğesi için birkaç DOM node'u göstermek {/*displaying-several-dom-nodes-for-each-list-item*/}
378380

379-
What do you do when each item needs to render not one, but several DOM nodes?
381+
Her öğenin bir değil birkaç DOM node'u render etmesi gerektiğinde ne yaparsınız?
380382

381-
The short [`<>...</>` Fragment](/reference/react/Fragment) syntax won't let you pass a key, so you need to either group them into a single `<div>`, or use the slightly longer and [more explicit `<Fragment>` syntax:](/reference/react/Fragment#rendering-a-list-of-fragments)
383+
Kısa [`<>...</>` Fragment](/reference/react/Fragment) syntax'ı bir anahtar belirlemenize izin vermez, bu nedenle tüm elementleri bir `<div>` elementi içinde gruplandırmanız ya da daha uzun olan [`<Fragment>` syntax'i](/reference/react/Fragment#rendering-a-list-of-fragments) kullanmalısınız.
382384

383385
```js
384386
import { Fragment } from 'react';
@@ -393,46 +395,46 @@ const listItems = people.map(person =>
393395
);
394396
```
395397

396-
Fragments disappear from the DOM, so this will produce a flat list of `<h1>`, `<p>`, `<h1>`, `<p>`, and so on.
398+
Fragmentler DOM'dan kaybolur, bu nedenle `<h1>`, `<p>`, `<h1>`, `<p>` gibi elementlerden oluşan düz bir liste oluşturulur.
397399

398400
</DeepDive>
399401

400-
### Where to get your `key` {/*where-to-get-your-key*/}
402+
### `anahtar` nereden gelir {/*where-to-get-your-key*/}
401403

402-
Different sources of data provide different sources of keys:
404+
Farklı veri kaynakları, farklı anahtar kaynakları sağlar:
403405

404-
* **Data from a database:** If your data is coming from a database, you can use the database keys/IDs, which are unique by nature.
405-
* **Locally generated data:** If your data is generated and persisted locally (e.g. notes in a note-taking app), use an incrementing counter, [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) or a package like [`uuid`](https://www.npmjs.com/package/uuid) when creating items.
406+
* **Veritabanından gelen veri:** Eğer veriniz bir veritabanından geliyorsa, doğasında ötürü zaten benzersiz olan veritabanı anahtarları/ID'leri kullanılabilir.
407+
* **Yerel olarak oluşturulmuş veriler:** Eğer veriniz yerel olarak oluşturuluyor ve saklanıyorsa (örneğin not alma aplikasyonundaki notlar), sıralı olarak artan numaralar [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) ya da [`uuid`](https://www.npmjs.com/package/uuid) gibi bir paket kullanabilirsiniz.
406408

407-
### Rules of keys {/*rules-of-keys*/}
409+
### Anahtarların kuralları {/*rules-of-keys*/}
408410

409-
* **Keys must be unique among siblings.** However, it’s okay to use the same keys for JSX nodes in _different_ arrays.
410-
* **Keys must not change** or that defeats their purpose! Don't generate them while rendering.
411+
* **Anahtarl kardeşler arasında benzersiz olmalıdır.** Ancak, _different_ dizilerdeki JSX node'ları için aynı anahtarları kullanmakta bir sakınca yoktur.
412+
* **Anahtarlar değişmemelidir.** yoksa bu anahtarların bütün amacını bozar! Anahtarları render etme sırasında üretmeyiniz.
411413

412-
### Why does React need keys? {/*why-does-react-need-keys*/}
414+
### React neden anahtarlara ihtiyaç duyar? {/*why-does-react-need-keys*/}
413415

414-
Imagine that files on your desktop didn't have names. Instead, you'd refer to them by their order -- the first file, the second file, and so on. You could get used to it, but once you delete a file, it would get confusing. The second file would become the first file, the third file would be the second file, and so on.
416+
Masaüstünüzdeki dosyaların isimlerinin olmadığını düşünün. Imagine that files on your desktop didn't have names. Bunun yerine, dosyalara sıralarına göre refere edersiniz -- ilk dosya, ikinci dosya gibi. Bu sisteme alışabilirsiniz ama bir dosyayı sildiğiniz zaman durum kafa karıştırıcı bir hale gelirdi. İkinci dosya birinci, üçüncü dosya ise ikinci dosya olurdu gibi.
415417

416-
File names in a folder and JSX keys in an array serve a similar purpose. They let us uniquely identify an item between its siblings. A well-chosen key provides more information than the position within the array. Even if the _position_ changes due to reordering, the `key` lets React identify the item throughout its lifetime.
418+
Dosya isimleri de dizilerdeki JSX anahtarları aynı amaca hizmet etmektedir. Anahtarlar, kardeşleri arasında bir öğeyi benzersiz bir şekilde tanımlamamıza olanak sağlar. İyi seçilmiş bir anahtar, dizi içindeki pozisyondan daha fazla bilgi sağlar. Öğenin _position_ yeniden sıralama nedeniyle değişse bile, `anahtar` React'in öğeyi döngü boyunca tanımasını sağlar.
417419

418420
<Pitfall>
419421

420-
You might be tempted to use an item's index in the array as its key. In fact, that's what React will use if you don't specify a `key` at all. But the order in which you render items will change over time if an item is inserted, deleted, or if the array gets reordered. Index as a key often leads to subtle and confusing bugs.
422+
Anahtar olarak dizideki bir öğenin dizinini kullanmak isteyebilirsiniz. Aslında, hiç bir `anahtar` belirtmezseniz React'in kullanacağı anahtar budur. Ancak, bir öğe eklenirse, silinirse veya dizi yeniden sıralanırsa, öğeleri oluşturma sıranız zaman içinde değişecektir. Bir anahtar olarak dizin, genellikle gizli ve kafa karıştırıcı hatalara yol açar.
421423

422-
Similarly, do not generate keys on the fly, e.g. with `key={Math.random()}`. This will cause keys to never match up between renders, leading to all your components and DOM being recreated every time. Not only is this slow, but it will also lose any user input inside the list items. Instead, use a stable ID based on the data.
424+
Benzer şekilde, anahtarları o anda oluşturmayın, örneğin `anahtar={Math.random()}` ile oluşturulan anahtarlar. Bu, anahtarların render etmeler arasında eşleşmemesine neden olarak tüm bileşenlerinizin ve DOM'un her seferinde yeniden oluşturulmasına yol açar. Bu sadece yavaş olmakla kalmaz, aynı zamanda liste öğeleri içindeki herhangi bir kullanıcı girdisini de kaybeder. Bunun yerine, verilere dayalı sabit bir ID kullanılmalıdır.
423425

424-
Note that your components won't receive `key` as a prop. It's only used as a hint by React itself. If your component needs an ID, you have to pass it as a separate prop: `<Profile key={id} userId={id} />`.
426+
Bileşenlerinizin prop olarak `anahtar` almayacağını unutmayın. Yalnıcaz React'in kendisi tarafından bir işaret olarak kullanılırlar. Eğer bileşeninizin bir ID'ye ihtiyacı varsa, ID'yi ayrı bir prop olarak şu şekilde kullanabilirsiniz: `<Profile key={id} userId={id} />`.
425427

426428
</Pitfall>
427429

428430
<Recap>
429431

430-
On this page you learned:
432+
Bu sayfada şunları öğrendiniz:
431433

432-
* How to move data out of components and into data structures like arrays and objects.
433-
* How to generate sets of similar components with JavaScript's `map()`.
434-
* How to create arrays of filtered items with JavaScript's `filter()`.
435-
* Why and how to set `key` on each component in a collection so React can keep track of each of them even if their position or data changes.
434+
* Verileri bileşenlerin dışına, diziler ve objeler gibi veri yapılarına taşıma.
435+
* JavaScript'in `map()` metodu ile benzer bileşen setleri oluşturma.
436+
* JavaScript'in `filter()` metodu ile filterenmiş öğe dizileri oluşturma.
437+
* React'in, konumları ya da verileri değişse bile her bir koleksiyondaki her bileşeni takip edebilmesi için `anahtar` neden ve nasıl kullanılır.
436438

437439
</Recap>
438440

0 commit comments

Comments
 (0)