You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`element`: The `element`argument must be a valid React element. For example, it could be a JSX node like `<Something />`, the result of calling[`createElement`](/reference/react/createElement), or the result of another`cloneElement`call.
50
+
*`element`: `element`argümanı geçerli bir React elementi olmalıdır. Örneğin `<Something />` gibi bir JSX node’u,[`createElement`](/reference/react/createElement) çağrısının sonucu veya başka bir`cloneElement`çağrısının sonucu olabilir.
51
51
52
-
*`props`: The `props`argument must either be an object or `null`. If you pass `null`, the cloned element will retain all of the original `element.props`. Otherwise, for every prop in the `props`object, the returned element will "prefer" the value from `props`over the value from `element.props`. The rest of the props will be filled from the original `element.props`. If you pass `props.key`or`props.ref`, they will replace the original ones.
52
+
*`props`: `props`argümanı bir obje veya `null` olmalıdır. Eğer `null` geçirirseniz, clone edilen element orijinal `element.props` değerlerini korur. Aksi takdirde, `props`objesindeki her prop için dönen element, `element.props`yerine `props` içindeki değeri "tercih eder". Geri kalan prop’lar orijinal `element.props`’tan doldurulur. Eğer `props.key`veya`props.ref` geçirirseniz, bunlar orijinal değerlerin yerini alır.
53
53
54
-
***optional**`...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes. If you don't pass any `...children`arguments, the original `element.props.children`will be preserved.
54
+
***opsiyonel**`...children`: Sıfır veya daha fazla child node. Bunlar React element’leri, string’ler, sayılar, [portals](/reference/react-dom/createPortal), boş node’lar (`null`, `undefined`, `true`, `false`) ve React node dizileri dahil olmak üzere herhangi bir React node olabilir. Eğer herhangi bir `...children`argümanı geçmezseniz, orijinal `element.props.children`korunur.
55
55
56
56
#### Returns {/*returns*/}
57
57
58
-
`cloneElement` returns a React element object with a few properties:
58
+
`cloneElement`, birkaç özelliğe sahip bir React element objesi döndürür:
59
59
60
-
*`type`: Same as `element.type`.
61
-
*`props`: The result of shallowly merging `element.props`with the overriding`props` you have passed.
62
-
*`ref`: The original `element.ref`, unless it was overridden by `props.ref`.
63
-
*`key`: The original `element.key`, unless it was overridden by `props.key`.
60
+
*`type`: `element.type` ile aynıdır.
61
+
*`props`: `element.props`ile verdiğiniz override`props`’un shallow merge edilmesi sonucu oluşur.
62
+
*`ref`: `props.ref` ile override edilmediyse, orijinal `element.ref`.
63
+
*`key`: `props.key` ile override edilmediyse, orijinal `element.key`.
64
64
65
-
Usually, you'll return the element from your component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it.
65
+
Genellikle, bu elementi component’inizden döndürür veya başka bir elementin child’ı olarak kullanırsınız. Element’in özelliklerini okuyabilseniz de, oluşturulduktan sonra her elementi opaque (iç yapısı bilinmeyen) olarak ele almak ve sadece render etmek en iyisidir.
66
66
67
-
#### Caveats {/*caveats*/}
67
+
#### Uyarılar {/*caveats*/}
68
68
69
-
*Cloning an element **does not modify the original element.**
69
+
*Bir elementi clone etmek **orijinal elementi değiştirmez.**
70
70
71
-
*You should only**pass children as multiple arguments to `cloneElement` if they are all statically known,**like`cloneElement(element, null, child1, child2, child3)`. If your children are dynamic, pass the entire array as the third argument: `cloneElement(element, null, listItems)`. This ensures that React will [warn you about missing `key`s](/learn/rendering-lists#keeping-list-items-in-order-with-key)for any dynamic lists. For static lists this is not necessary because they never reorder.
71
+
*`children`’ları `cloneElement`’e yalnızca**tamamı statik olarak biliniyorsa çoklu argümanlar şeklinde geçmelisiniz,**örneğin`cloneElement(element, null, child1, child2, child3)`. Eğer `children` dinamik ise, tüm diziyi üçüncü argüman olarak geçin: `cloneElement(element, null, listItems)`. Bu, React’in dinamik listeler için [eksik `key` uyarısı vermesini](/learn/rendering-lists#keeping-list-items-in-order-with-key)sağlar. Statik listeler için bu gerekli değildir çünkü yeniden sıralanmazlar.
72
72
73
-
*`cloneElement` makes it harder to trace the data flow, so **try the [alternatives](#alternatives)instead.**
73
+
*`cloneElement`, veri akışını takip etmeyi zorlaştırır, bu yüzden **bunun yerine [alternatifleri](#alternatives)kullanmayı deneyin.**
74
74
75
75
---
76
76
77
-
## Usage {/*usage*/}
77
+
## Kullanım {/*usage*/}
78
78
79
-
### Overriding props of an element {/*overriding-props-of-an-element*/}
79
+
### Bir öğenin özelliklerini geçersiz kılma {/*overriding-props-of-an-element*/}
80
80
81
-
To override the props of some <CodeStepstep={1}>React element</CodeStep>, pass it to `cloneElement` with the <CodeStepstep={2}>props you want to override</CodeStep>:
81
+
Bazı <CodeStepstep={1}>React element</CodeStep> prop’larını override etmek için, onu `cloneElement`’e <CodeStepstep={2}>override etmek istediğiniz props</CodeStep> ile geçirin:
Here, the resulting <CodeStepstep={3}>cloned element</CodeStep> will be `<Row title="Cabbage" isHighlighted={true} />`.
93
+
Burada, ortaya çıkan <CodeStepstep={3}>cloned element</CodeStep> `<Row title="Cabbage" isHighlighted={true} />` olacaktır.
94
94
95
-
**Let's walk through an example to see when it's useful.**
95
+
**Ne zaman kullanışlı olduğunu görmek için bir örnek üzerinden gidelim.**
96
96
97
-
Imagine a `List` component that renders its[`children`](/learn/passing-props-to-a-component#passing-jsx-as-children)as a list of selectable rows with a "Next" button that changes which row is selected. The `List` component needs to render the selected `Row` differently, so it clones every `<Row>` child that it has received, and adds an extra `isHighlighted: true`or`isHighlighted: false` prop:
97
+
Bir `List` component’ini düşünün; bu component[`children`](/learn/passing-props-to-a-component#passing-jsx-as-children)öğelerini, seçilebilir satırlar listesi olarak render eder ve hangi satırın seçili olduğunu değiştiren bir "Next" butonu vardır. `List` component’i seçili `Row`’u farklı render etmesi gerektiğinden, aldığı her `<Row>` child’ını clone eder ve ekstra bir `isHighlighted: true`veya`isHighlighted: false` prop’u ekler:
98
98
99
99
```js {6-8}
100
100
exportdefaultfunctionList({ children }) {
@@ -108,7 +108,7 @@ export default function List({ children }) {
108
108
)}
109
109
```
110
110
111
-
Let's say the original JSX received by `List` looks like this:
111
+
Diyelim ki `List`’in aldığı orijinal JSX şöyle görünüyor:
112
112
113
113
```js {2-4}
114
114
<List>
@@ -118,7 +118,7 @@ Let's say the original JSX received by `List` looks like this:
118
118
</List>
119
119
```
120
120
121
-
By cloning its children, the `List`can pass extra information to every `Row` inside. The result looks like this:
121
+
Children’larını clone ederek, `List`her bir `Row`’a ekstra bilgi geçirebilir. Sonuç şöyle görünür:
122
122
123
123
```js {4,8,12}
124
124
<List>
@@ -137,7 +137,7 @@ By cloning its children, the `List` can pass extra information to every `Row` in
137
137
</List>
138
138
```
139
139
140
-
Notice how pressing "Next" updates the state of the `List`, and highlights a different row:
140
+
“Next” butonuna basıldığında `List`’in state’inin nasıl güncellendiğine ve farklı bir satırın highlight edildiğine dikkat edin:
141
141
142
142
<Sandpack>
143
143
@@ -232,21 +232,21 @@ button {
232
232
233
233
</Sandpack>
234
234
235
-
To summarize, the `List`cloned the `<Row />`elements it received and added an extra prop to them.
235
+
Özetle, `List`aldığı `<Row />`elementlerini clone etti ve bunlara ekstra bir prop ekledi.
236
236
237
237
<Pitfall>
238
238
239
-
Cloning children makes it hard to tell how the data flows through your app. Try one of the [alternatives.](#alternatives)
239
+
Children’ları clone etmek, veri akışının uygulamanızda nasıl ilerlediğini anlamayı zorlaştırır. [Alternatiflerden](#alternatives) birini denemeyi deneyin.
240
240
241
241
</Pitfall>
242
242
243
243
---
244
244
245
-
## Alternatives {/*alternatives*/}
245
+
## Alternatifler {/*alternatives*/}
246
246
247
-
### Passing data with a render prop {/*passing-data-with-a-render-prop*/}
247
+
### Render prop ile veri aktarımı {/*passing-data-with-a-render-prop*/}
248
248
249
-
Instead of using `cloneElement`, consider accepting a *render prop* like `renderItem`. Here,`List` receives `renderItem` as a prop. `List` calls `renderItem` for every item and passes `isHighlighted` as an argument:
249
+
`cloneElement` kullanmak yerine, `renderItem` gibi bir *render prop* kabul etmeyi düşünebilirsiniz. Burada`List`, `renderItem`’ı bir prop olarak alır. `List`, her item için `renderItem`’ı çağırır ve `isHighlighted`’ı bir argüman olarak geçirir:
The `renderItem` prop is called a "render prop" because it's a prop that specifies how to render something. For example, you can pass a `renderItem` implementation that renders a `<Row>`with the given `isHighlighted` value:
262
+
`renderItem` prop’una "render prop" denir çünkü bir şeyin nasıl render edileceğini belirten bir prop’tur. Örneğin, verilen `isHighlighted` değeri ile bir `<Row>`render eden bir `renderItem` implementasyonu geçebilirsiniz:
263
263
264
264
```js {3,7}
265
265
<List
@@ -274,7 +274,7 @@ The `renderItem` prop is called a "render prop" because it's a prop that specifi
274
274
/>
275
275
```
276
276
277
-
The end result is the same as with `cloneElement`:
277
+
Sonuç, `cloneElement` kullanımıyla elde edilen ile aynıdır:
278
278
279
279
```js {4,8,12}
280
280
<List>
@@ -293,7 +293,7 @@ The end result is the same as with `cloneElement`:
293
293
</List>
294
294
```
295
295
296
-
However, you can clearly trace where the `isHighlighted`value is coming from.
296
+
Ancak, `isHighlighted`değerinin nereden geldiğini açıkça takip edebilirsiniz.
297
297
298
298
<Sandpack>
299
299
@@ -389,22 +389,21 @@ button {
389
389
390
390
</Sandpack>
391
391
392
-
This pattern is preferred to `cloneElement` because it is more explicit.
392
+
Bu desen, `cloneElement`’e göre tercih edilir çünkü daha açıktır.
393
393
394
394
---
395
395
396
-
### Passing data through context {/*passing-data-through-context*/}
396
+
### Veriyi context üzerinden geçirmek {/*passing-data-through-context*/}
397
397
398
-
Another alternative to `cloneElement` is to [pass data through context.](/learn/passing-data-deeply-with-context)
398
+
`cloneElement`’e bir diğer alternatif ise veriyi [context üzerinden geçirmektir.](/learn/passing-data-deeply-with-context)
399
399
400
-
401
-
For example, you can call [`createContext`](/reference/react/createContext) to define a `HighlightContext`:
400
+
Örneğin, bir `HighlightContext` tanımlamak için [`createContext`](/reference/react/createContext) çağırabilirsiniz:
402
401
403
402
```js
404
403
exportconstHighlightContext=createContext(false);
405
404
```
406
405
407
-
Your `List`component can wrap every item it renders into a `HighlightContext`provider:
406
+
`List`bileşeniniz, render ettiği her bir öğeyi bir `HighlightContext`sağlayıcısı içine sarabilir:
With this approach, `Row`does not need to receive an `isHighlighted` prop at all. Instead, it reads the context:
423
+
Bu yaklaşımla, `Row`bileşeninin artık bir `isHighlighted` prop’u almasına gerek yoktur. Bunun yerine, context’i okur:
425
424
426
425
```js src/Row.js {2}
427
426
exportdefaultfunctionRow({ title }) {
428
427
constisHighlighted=useContext(HighlightContext);
429
428
// ...
430
429
```
431
430
432
-
This allows the calling component to not know or worry about passing `isHighlighted` to `<Row>`:
431
+
Bu, çağıran bileşenin `<Row>` bileşenine `isHighlighted` prop’unu geçmek zorunda kalmamasını ve bununla ilgilenmemesini sağlar:
433
432
434
433
```js {4}
435
434
<List
@@ -440,7 +439,7 @@ This allows the calling component to not know or worry about passing `isHighligh
440
439
/>
441
440
```
442
441
443
-
Instead, `List`and`Row` coordinate the highlighting logic through context.
442
+
Bunun yerine, `List`ve`Row`, highlight (vurgulama) mantığını context üzerinden koordine eder:
444
443
445
444
<Sandpack>
446
445
@@ -550,13 +549,13 @@ button {
550
549
551
550
</Sandpack>
552
551
553
-
[Learn more about passing data through context.](/reference/react/useContext#passing-data-deeply-into-the-tree)
552
+
[Context aracılığıyla veri aktarma hakkında daha fazla bilgi edinin.](/reference/react/useContext#passing-data-deeply-into-the-tree)
554
553
555
554
---
556
555
557
-
### Extracting logic into a custom Hook {/*extracting-logic-into-a-custom-hook*/}
556
+
### Mantığı özel bir Hook içine çıkarma {/*extracting-logic-into-a-custom-hook*/}
558
557
559
-
Another approach you can try is to extract the "non-visual" logic into your own Hook, and use the information returned by your Hook to decide what to render. For example, you could write a `useList`custom Hook like this:
558
+
Deneyebileceğiniz bir diğer yaklaşım, "görsel olmayan" mantığı kendi Hook’unuza çıkarmak ve Hook’unuzun döndürdüğü bilgilere göre neyin render edileceğine karar vermektir. Örneğin, aşağıdaki gibi bir `useList`özel Hook’u yazabilirsiniz:
560
559
561
560
```js
562
561
import { useState } from'react';
@@ -575,7 +574,7 @@ export default function useList(items) {
575
574
}
576
575
```
577
576
578
-
Then you could use it like this:
577
+
Ardından bunu şu şekilde kullanabilirsiniz:
579
578
580
579
```js {2,9,13}
581
580
exportdefaultfunctionApp() {
@@ -598,7 +597,7 @@ export default function App() {
598
597
}
599
598
```
600
599
601
-
The data flow is explicit, but the state is inside the `useList` custom Hook that you can use from any component:
600
+
Veri akışı nettir (explicit), ancak state `useList` custom Hook’unun içindedir ve bunu herhangi bir bileşenden kullanabilirsiniz:
602
601
603
602
<Sandpack>
604
603
@@ -691,4 +690,4 @@ button {
691
690
692
691
</Sandpack>
693
692
694
-
This approach is particularly useful if you want to reuse this logic between different components.
693
+
Bu yaklaşım, bu mantığı farklı bileşenler arasında yeniden kullanmak istediğiniz durumlarda özellikle faydalıdır.
0 commit comments