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
Call `findDOMNode` to find the browser DOM node for a given React [class component](/reference/react/Component)instance.
29
+
Bir React [sınıf bileşenine](/reference/react/Component)ait DOM düğümünü bulmak için `findDOMNode` fonksiyonunu çağırın.
30
30
31
31
```js
32
32
import { findDOMNode } from'react-dom';
33
33
34
34
constdomNode=findDOMNode(componentInstance);
35
35
```
36
36
37
-
[See more examples below.](#usage)
37
+
[Daha fazla kullanım örneği için buraya tıklayın.](#usage)
38
38
39
-
#### Parameters {/*parameters*/}
39
+
#### Parametreler {/*parameters*/}
40
40
41
-
*`componentInstance`: An instance of the [`Component`](/reference/react/Component)subclass. For example, `this`inside a class component.
41
+
*`componentInstance`: [`Bileşene`](/reference/react/Component)ait nesneyi ifade eder. Örnekle, React sınıf bileşeni içerisinde kullanılan `this`işaretcisi parametre olarak kullanılabilir.
42
42
43
43
44
-
#### Returns {/*returns*/}
44
+
#### Dönüş Değerleri {/*returns*/}
45
45
46
-
`findDOMNode` returns the first closest browser DOM node within the given `componentInstance`. When a component renders to `null`, or renders `false`, `findDOMNode`returns`null`. When a component renders to a string, `findDOMNode` returns a text DOM node containing that value.
46
+
`findDOMNode`, verilen `componentInstance` bileşenini içeren en yakın DOM düğümünü döndürür. Eğer bir bileşen `null` veya `false` olarak render edilirse, `findDOMNode`fonksiyonu`null` değerini döndürür. Eğer bileşen sadece metin içerecek şekilde render edilirse, `findDOMNode`, o değeri içeren bir metin DOM nesnesi döndürür.
47
47
48
-
#### Caveats {/*caveats*/}
48
+
#### Uyarılar {/*caveats*/}
49
49
50
-
*A component may return an array or a [Fragment](/reference/react/Fragment)with multiple children. In that case `findDOMNode`, will return the DOM node corresponding to the first non-empty child.
50
+
*React bileşeni bazı durumlarda bir [Fragment](/reference/react/Fragment)ya da bir dizi içerebilir. Bu durumda `findDOMNode` fonsiyonu içi boş olmayan ilk alt nesneyi döndürecektir.
51
51
52
-
*`findDOMNode`only works on mounted components (that is, components that have been placed in the DOM). If you try to call this on a component that has not been mounted yet (like calling `findDOMNode()`in `render()`on a component that has yet to be created), an exception will be thrown.
52
+
*`findDOMNode`fonksiyonu sadece render edilmiş bileşenlerde çalışır. (Yani, bir bileşenin DOM üzerinde bir yer edinmiş olması gerekir). Eğer render edilmemiş bir bileşen için `findDOMNode` fonksiyonunu çağırmaya çalışırsanız (Örn: `findDOMNode()`fonksiyonunu, henüz oluşturulmamış bir bileşenin `render()`fonksiyonu içerisinde çağırırsanız) uygulama genelinde bir hata fırlatılır ve uygulama çalışmaz.
53
53
54
-
*`findDOMNode`only returns the result at the time of your call. If a child component renders a different node later, there is no way for you to be notified of this change.
54
+
*`findDOMNode`fonksiyonu sadece çağırıldığı andaki sonucu döndürür. Eğer alt bileşen daha sonradan farklı bir node render eder ise bu değişimden haberdar olmak mümkün değildir.
55
55
56
-
*`findDOMNode`accepts a class component instance, so it can't be used with function components.
56
+
*`findDOMNode`sadece React sınıf bileşenleri ile çalışır, React fonksiyon bileşeni yapısı ile kullanılamaz.
57
57
58
58
---
59
59
60
-
## Usage {/*usage*/}
60
+
## Kullanım {/*usage*/}
61
61
62
-
### Finding the root DOM node of a class component {/*finding-the-root-dom-node-of-a-class-component*/}
62
+
### Sınıf bileşeninin ana DOM objesinin bulunması {/*finding-the-root-dom-node-of-a-class-component*/}
63
+
64
+
Render edilmiş DOM düğümünü bulabilmek için `findDOMNode` fonksiyonunu bir React sınıf bileşeni içerisinde çağırın. (React sınıf bileşenine `this` niteliğini kullanarak erişebilirsiniz)
63
65
64
-
Call `findDOMNode` with a [class component](/reference/react/Component) instance (usually, `this`) to find the DOM node it has rendered.
65
66
66
67
```js {3}
67
68
classAutoselectingInputextendsComponent {
@@ -71,12 +72,20 @@ class AutoselectingInput extends Component {
71
72
}
72
73
73
74
render() {
74
-
return<input defaultValue="Hello"/>
75
+
return<input defaultValue="Merhaba"/>
75
76
}
76
77
}
77
78
```
78
79
79
-
Here, the `input` variable will be set to the `<input>` DOM element. This lets you do something with it. For example, when clicking "Show example" below mounts the input, [`input.select()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select) selects all text in the input:
80
+
Yukarıdaki kod parçacığında `ìnput` değişkeni `findDOMNode` fonksiyonu aracılığı ile render metodu içerisindeki `<input>` DOM nesnesine ulaşır.
81
+
82
+
Şimdi ulaşılan input nesnesiyle bir şeyler yapalım. Bir `show` state'i oluşturalım ve varsayılan değeri `false` olsun. `Göster` buton elementi aracılığı ile state'i güncelleyelim. Güncellenen `show` state'i ile `<AutoSelectingInput />` bileşeni render edilsin.
83
+
84
+
Alt tarafta gerekli kaynak kodu görüntüleyebilirsiniz, şimdi de neler olduğunu açıklayalım.
85
+
86
+
`Göster` butonuna tıklandığında `AutoselectingInput` bileşeni render edilir ve tarayıcı ekranında görünür hale gelir. Ardından `findDOMNode` fonksiyonu çağrılarak input nesnesi bulunur.
87
+
88
+
Bulunan nesnede [`input.select()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select) metodu aracılığı ile içinde yazılı olan `Merhaba` yazısı seçili olarak gösterilir.
80
89
81
90
<Sandpack>
82
91
@@ -89,7 +98,7 @@ export default function App() {
89
98
return (
90
99
<>
91
100
<button onClick={() =>setShow(true)}>
92
-
Show example
101
+
Göster
93
102
</button>
94
103
<hr />
95
104
{show &&<AutoselectingInput />}
@@ -109,7 +118,7 @@ class AutoselectingInput extends Component {
### Reading component's own DOM node from a ref {/*reading-components-own-dom-node-from-a-ref*/}
134
+
### Referans değerinden bileşene ait DOM nesnesine ulaşma {/*reading-components-own-dom-node-from-a-ref*/}
126
135
127
-
Code using `findDOMNode`is fragile because the connection between the JSX node and the code manipulating the corresponding DOM node is not explicit. For example, try wrapping this `<input />`into a `<div>`:
136
+
`findDOMNode`fonksiyonunun kullanıldığı kodlar kırılgan kodlardır. Çünkü JSX nesnesi ile DOM nesnesi arasındaki bağlantı açık bir şekilde ifade edilmemektedir. Örn, kod içerisindeki `<input />`kısmını `<div>` ile sarmayı deneyelim:
128
137
129
138
<Sandpack>
130
139
@@ -137,7 +146,7 @@ export default function App() {
137
146
return (
138
147
<>
139
148
<button onClick={() =>setShow(true)}>
140
-
Show example
149
+
Göster
141
150
</button>
142
151
<hr />
143
152
{show &&<AutoselectingInput />}
@@ -156,7 +165,7 @@ class AutoselectingInput extends Component {
This will break the code because now, `findDOMNode(this)` finds the `<div>` DOM node, but the code expects an `<input>` DOM node. To avoid these kinds of problems, use [`createRef`](/reference/react/createRef) to manage a specific DOM node.
177
+
Bu kullanım kodun çalışmasına engel olacaktır. Çünkü `findDOMNode` geriye `<div>` DOM düğümünü döndürecektir fakat kod dönüş değerinin `<input />` DOM nesnesi olmasını bekler.
178
+
179
+
Bu tür problemlerin önüne geçmek spesifik bir DOM nesnesi seçebilen için [`createRef`](/reference/react/createRef) fonksiyonunu kullanın.
169
180
170
-
In this example, `findDOMNode` is no longer used. Instead, `inputRef = createRef(null)` is defined as an instance field on the class. To read the DOM node from it, you can use `this.inputRef.current`. To attach it to the JSX, you render `<input ref={this.inputRef} />`. This connects the code using the DOM node to its JSX:
181
+
Alt kısımdaki örnekte `findDOMNode` yerine `createRef`'in nasıl kullanıdğını daha iyi anlayabilirsiniz.
182
+
183
+
Bu örnekte, `ìnputRef = createRef(null)` kodunda `null` değer tanımlamasına sahip yeni bir referans oluşturduk. Oluşturduğumuz bu referansı `ref={this.inputRef}` niteliği aracılığıyla `input` elementine tanımladık.
184
+
185
+
Bileşen oluşturulduğunda ise `this.inputRef.current` notasyonu ile DOM nesnesine ulaştık ve `input.select()` metodunu yeniden kullanılabilir hale getirdik.
In modern React without class components, the equivalent code would call [`useRef`](/reference/react/useRef) instead:
230
+
Bahsettiğimiz üzere `findDOMNode` fonksiyon bileşenlerini desteklemiyordu. Referans sisteminde sınırlama olmadan fonksiyon bileşenlerinde de kullanabiliyoruz.
231
+
232
+
Fonksiyon bileşenlerindeki referans kullanımında `createRef` yerini [`useRef`](/reference/react/useRef) hook'u almakta.
216
233
217
234
<Sandpack>
218
235
@@ -225,7 +242,7 @@ export default function App() {
225
242
return (
226
243
<>
227
244
<button onClick={() =>setShow(true)}>
228
-
Show example
245
+
Göster
229
246
</button>
230
247
<hr />
231
248
{show &&<AutoselectingInput />}
@@ -245,19 +262,19 @@ export default function AutoselectingInput() {
[Read more about manipulating the DOM with refs.](/learn/manipulating-the-dom-with-refs)
271
+
[Ref'ler ile DOM manipülasyonu hakkında daha fazla bilgi almak için tıklayın.](/learn/manipulating-the-dom-with-refs)
255
272
256
273
---
257
274
258
-
### Reading a child component's DOM node from a forwarded ref {/*reading-a-child-components-dom-node-from-a-forwarded-ref*/}
275
+
### Alt bileşene ait DOM nesnesine forwarded ref aracılığı ile ulaşma {/*reading-a-child-components-dom-node-from-a-forwarded-ref*/}
259
276
260
-
In this example, `findDOMNode(this)`finds a DOM node that belongs to another component. The `AutoselectingInput`renders `MyInput`, which is your own component that renders a browser `<input>`.
277
+
Bu örnekte, `findDOMNode(this)`ile başka bir bileşene ait DOM düğümünü bulacağız. `AutoselectingInput`bileşeni, `input` elementinin bulunduğu `MyInput` bileşenini render edecek ve `findDOMNode(this)` fonksiyonunu kullanarak `input` elementine ulaşmaya çalışacağız.
261
278
262
279
<Sandpack>
263
280
@@ -305,14 +322,14 @@ export default function MyInput() {
305
322
306
323
</Sandpack>
307
324
308
-
Notice that calling `findDOMNode(this)`inside `AutoselectingInput` still gives you the DOM `<input>`--even though the JSX for this `<input>`is hidden inside the `MyInput`component. This seems convenient for the above example, but it leads to fragile code. Imagine that you wanted to edit`MyInput` later and add a wrapper `<div>`around it. This would break the code of`AutoselectingInput`(which expects to find an `<input>`).
325
+
`AutoselectingInput` içindeki `findDOMNode(this)`çağrısının size hala DOM `<input>` verdiğini unutmayın; bu `<input>`için JSX `MyInput`bileşeninin içinde gizli olsa bile. Bu, yukarıdaki örnek için uygun gibi görünse de kodun kırılgan olmasına neden olur. Daha sonra`MyInput`'u düzenlemek ve etrafına bir `<div>`sarmalayıcısı eklemek istediğinizi düşünün. Bu durumda, (bir `<input>` bulmayı bekleyen)`AutoselectingInput`bileşeni doğru çalışmayacaktır.
309
326
310
-
To replace `findDOMNode`in this example, the two components need to coordinate:
327
+
`findDOMNode`yerine ref kullanabilmemiz için iki bileşende de belirli düzenlemeler yapmalıyız.
311
328
312
-
1.`AutoSelectingInput` should declare a ref, like [in the earlier example](#reading-components-own-dom-node-from-a-ref), and pass it to `<MyInput>`.
313
-
2.`MyInput`should be declared with [`forwardRef`](/reference/react/forwardRef)to take that ref and forward it down to the `<input>` node.
329
+
1.[Önceki örneklerde](#reading-components-own-dom-node-from-a-ref) işlediğimiz üzere `AutoSelectingInput` içinde bir referans tanımlamalıyız ve bu referansı `MyInput` bileşenine iletmeliyiz.
330
+
2.`MyInput`bileşeni ise [`forwardRef`](/reference/react/forwardRef)aracılığı ile bir referans değer döndürmeli ki ortadaki iki referans değeri birbiriyle eşleşsin ve üst bileşen yapısında `input` elementine ait referansı kullanabilelim.
314
331
315
-
This version does that, so it no longer needs `findDOMNode`:
332
+
Nihai versiyonda artık `findDOMNode` kullanmadan başka bir bileşen içindeki DOM nesnesine erişebildik:
316
333
317
334
<Sandpack>
318
335
@@ -325,7 +342,7 @@ export default function App() {
### Adding a wrapper `<div>` element {/*adding-a-wrapper-div-element*/}
440
+
### Kapsayıcı `<div>` elementi ekleme {/*adding-a-wrapper-div-element*/}
441
+
442
+
Bazen bir bileşenin alt bileşenlerinin konumunu ve boyutunu bilmesi gerekir. Bu durum, `findDOMNode(this)` ile bulunan nesnelerle ve ardından ölçümler için bu nesnelerin [`getBoundingClientRect`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) gibi DOM yöntemleriyle kullanılmasıyla sonuçlanır.
424
443
425
-
Sometimes a component needs to know the position and size of its children. This makes it tempting to find the children with `findDOMNode(this)`, and then use DOM methods like [`getBoundingClientRect`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) for measurements.
444
+
Şu anda bu kullanım için doğrudan bir alternatif yoktur, bu nedenle `findDOMNode` kullanımdan kaldırılmış olsa da henüz React'tan tamamen kaldırılmamıştır.
426
445
427
-
There is currently no direct equivalent for this use case, which is why `findDOMNode` is deprecated but is not yet removed completely from React. In the meantime, you can try rendering a wrapper `<div>`node around the content as a workaround, and getting a ref to that node. However, extra wrappers can break styling.
446
+
Bu durumda çözüm olarak içeriği kapasayacak bir `<div>` elementi oluşturabilirsiniz ve oluşturduğunuz `<div>`elementine bir referans tanımlayabilirsiniz. Ancak unutmamak gerekir ki ekstra oluşturduğunuz kapsayıcılar stil bozulmalarına sebep olabilir.
428
447
429
448
```js
430
449
<div ref={someRef}>
431
450
{children}
432
451
</div>
433
452
```
434
453
435
-
This also applies to focusing and scrolling to arbitrary children.
454
+
Bu aynı zamanda alt bileşenlere `focusing` ve `scrolling` olayları için de geçerlidir.
0 commit comments