Skip to content

Commit 369e4d4

Browse files
authored
Merge pull request #415 from baspinarenes/enesbaspinar/userid
translate useid
2 parents 3d185cd + 863959f commit 369e4d4

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

src/content/reference/react/useId.md

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: useId
44

55
<Intro>
66

7-
`useId` is a React Hook for generating unique IDs that can be passed to accessibility attributes.
7+
`useId`, erişilebilirlik özniteliklerine iletmek üzere benzersiz kimlikler üreten React Hook'udur.
88

99
```js
1010
const id = useId()
@@ -16,11 +16,11 @@ const id = useId()
1616

1717
---
1818

19-
## Reference {/*reference*/}
19+
## Referans {/*reference*/}
2020

2121
### `useId()` {/*useid*/}
2222

23-
Call `useId` at the top level of your component to generate a unique ID:
23+
Benzersiz bir kimlik oluşturmak için `useId`'yi bileşeninizin kök kapsamında çağırın:
2424

2525
```js
2626
import { useId } from 'react';
@@ -30,35 +30,35 @@ function PasswordField() {
3030
// ...
3131
```
3232
33-
[See more examples below.](#usage)
33+
[Daha fazla örnek için aşağıya bakın.](#usage)
3434
35-
#### Parameters {/*parameters*/}
35+
#### Parametreler {/*parameters*/}
3636
37-
`useId` does not take any parameters.
37+
Herhangi bir parametre almaz.
3838
39-
#### Returns {/*returns*/}
39+
#### Dönüş Değerleri {/*returns*/}
4040
41-
`useId` returns a unique ID string associated with this particular `useId` call in this particular component.
41+
Çağrıldığı bileşene özel olarak her bir `useId` çağrısı için _karakter dizisi (string)_ tipinde benzersiz kimlik döner.
4242
43-
#### Caveats {/*caveats*/}
43+
#### Uyarılar {/*caveats*/}
4444
45-
* `useId` is a Hook, so you can only call it **at the top level of your component** or your own Hooks. You can't call it inside loops or conditions. If you need that, extract a new component and move the state into it.
45+
* `useId` bir Hook olduğundan, yalnızca **bileşeninizin kök kapsamında** ya da kendi Hook'larınızda çağırabilirsiniz. Döngülerin ve koşulların içinde çağıramazsınız. Eğer çağırmak zorunda kaldıysanız yeni bir bileşene çıkarın ve state'i ona taşıyın.
4646
47-
* `useId` **should not be used to generate keys** in a list. [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
47+
* Liste elemanlarına **anahtar üretmek için kullanılmamalıdır**. [Anahtarlar elinizdeki veriden üretilmelidir.](/learn/rendering-lists#where-to-get-your-key)
4848
4949
---
5050
51-
## Usage {/*usage*/}
51+
## Kullanım {/*usage*/}
5252
5353
<Pitfall>
5454
55-
**Do not call `useId` to generate keys in a list.** [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
55+
**Anahtar üretmek için `useId` kullanmayın**. [Anahtarlar elinizdeki veriden üretilmelidir.](/learn/rendering-lists#where-to-get-your-key)
5656
5757
</Pitfall>
5858
59-
### Generating unique IDs for accessibility attributes {/*generating-unique-ids-for-accessibility-attributes*/}
59+
### Erişilebilirlik öznitelikleri için benzersiz kimlikler üretmek {/*generating-unique-ids-for-accessibility-attributes*/}
6060
61-
Call `useId` at the top level of your component to generate a unique ID:
61+
Bileşeninizin kök kapsamında benzersiz kimlikler üretmek için `useId`'yi çağırın:
6262
6363
```js [[1, 4, "passwordHintId"]]
6464
import { useId } from 'react';
@@ -68,7 +68,7 @@ function PasswordField() {
6868
// ...
6969
```
7070
71-
You can then pass the <CodeStep step={1}>generated ID</CodeStep> to different attributes:
71+
Daha sonra <CodeStep step={1}>oluşturulan kimliği</CodeStep> farklı özniteliklere iletebilirsiniz:
7272
7373
```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]]
7474
<>
@@ -77,26 +77,26 @@ You can then pass the <CodeStep step={1}>generated ID</CodeStep> to different at
7777
</>
7878
```
7979
80-
**Let's walk through an example to see when this is useful.**
80+
**Bunun ne zaman faydalı olabileceğini görmek için bir örnek üzerinden ilerleyelim.**
8181
82-
[HTML accessibility attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) like [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) let you specify that two tags are related to each other. For example, you can specify that an element (like an input) is described by another element (like a paragraph).
82+
[`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) gibi [HTML erişilebilirlik öznitelikleri](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA), iki etiketin birbirine bağlı olduğunu belirtmenizi sağlar. Örneğin, bir elementin (mesela `<input>`) başka bir element (mesela `<p>`) tarafından tanımlandığını belirtebilirsiniz.
8383
84-
In regular HTML, you would write it like this:
84+
Saf HTML'de bunu şu şekilde yazarsınız:
8585
8686
```html {5,8}
8787
<label>
88-
Password:
88+
Şifre:
8989
<input
9090
type="password"
9191
aria-describedby="password-hint"
9292
/>
9393
</label>
9494
<p id="password-hint">
95-
The password should contain at least 18 characters
95+
Şifre en az 18 karakter içermelidir
9696
</p>
9797
```
9898
99-
However, hardcoding IDs like this is not a good practice in React. A component may be rendered more than once on the page--but IDs have to be unique! Instead of hardcoding an ID, generate a unique ID with `useId`:
99+
Ancak, doğrudan koda yazılan kimlikler React'ta iyi bir pratik değildir. Bir bileşen sayfada birden fazla kez render edilebilir--ancak kimlikler benzersiz olmalıdır! Bunun yerine `useId` ile benzersiz bir kimlik oluşturun:
100100
101101
```js {4,11,14}
102102
import { useId } from 'react';
@@ -106,21 +106,21 @@ function PasswordField() {
106106
return (
107107
<>
108108
<label>
109-
Password:
109+
Şifre:
110110
<input
111111
type="password"
112112
aria-describedby={passwordHintId}
113113
/>
114114
</label>
115115
<p id={passwordHintId}>
116-
The password should contain at least 18 characters
116+
Şifre en az 18 karakter içermelidir
117117
</p>
118118
</>
119119
);
120120
}
121121
```
122122
123-
Now, even if `PasswordField` appears multiple times on the screen, the generated IDs won't clash.
123+
Artık `PasswordField` ekranda birden fazla kez görünse bile üretilen kimlikler çakışmaz.
124124
125125
<Sandpack>
126126
@@ -132,14 +132,14 @@ function PasswordField() {
132132
return (
133133
<>
134134
<label>
135-
Password:
135+
Şifre:
136136
<input
137137
type="password"
138138
aria-describedby={passwordHintId}
139139
/>
140140
</label>
141141
<p id={passwordHintId}>
142-
The password should contain at least 18 characters
142+
Şifre en az 18 karakter içermelidir
143143
</p>
144144
</>
145145
);
@@ -148,9 +148,9 @@ function PasswordField() {
148148
export default function App() {
149149
return (
150150
<>
151-
<h2>Choose password</h2>
151+
<h2>Şifreni seç</h2>
152152
<PasswordField />
153-
<h2>Confirm password</h2>
153+
<h2>Şifreni doğrula</h2>
154154
<PasswordField />
155155
</>
156156
);
@@ -163,33 +163,33 @@ input { margin: 5px; }
163163
164164
</Sandpack>
165165
166-
[Watch this video](https://www.youtube.com/watch?v=0dNzNcuEuOo) to see the difference in the user experience with assistive technologies.
166+
Yardımcı teknolojiler ile edinilen kullanıcı deneyiminde yarattığı farkı görmek için [bu videoyu izleyin](https://www.youtube.com/watch?v=0dNzNcuEuOo).
167167
168168
<Pitfall>
169169
170-
With [server rendering](/reference/react-dom/server), **`useId` requires an identical component tree on the server and the client**. If the trees you render on the server and the client don't match exactly, the generated IDs won't match.
170+
[Sunucu taraflı render](/reference/react-dom/server) ile birlikte kullanılan **`useId`, sunucu ve istemci tarafında özdeş bileşen ağacına gereksinim duyar**. Sunucu ve istemcide render edilen ağaçlar birebir eşleşmezse, oluşan kimlikler de eşleşmeyecektir.
171171
172172
</Pitfall>
173173
174174
<DeepDive>
175175
176-
#### Why is useId better than an incrementing counter? {/*why-is-useid-better-than-an-incrementing-counter*/}
176+
#### Neden useId kullanmak artan bir sayaca nazaran daha iyidir? {/*why-is-useid-better-than-an-incrementing-counter*/}
177177
178-
You might be wondering why `useId` is better than incrementing a global variable like `nextId++`.
178+
`useId`'nin `nextId++` gibi global bir değişkeni arttırmaktan neden daha iyi olduğunu merak ediyor olabilirsiniz.
179179
180-
The primary benefit of `useId` is that React ensures that it works with [server rendering.](/reference/react-dom/server) During server rendering, your components generate HTML output. Later, on the client, [hydration](/reference/react-dom/client/hydrateRoot) attaches your event handlers to the generated HTML. For hydration to work, the client output must match the server HTML.
180+
Temel avantajı, React'ın [sunucu taraflı render](/reference/react-dom/server) ile çalışacağını garanti etmesidir. Bileşenleriniz sunucu taraflı render ensasında HTML çıktısı üretir. Ardından istemcide, üretilen HTML'e [hidratlama](/reference/react-dom/client/hydrateRoot) (hydration) sırasında olay yöneticileri eklenir. Hidratlamanın çalışması için, istemci çıktısının sunucu HTML'iyle eşleşmesi gerekir.
181181
182-
This is very difficult to guarantee with an incrementing counter because the order in which the client components are hydrated may not match the order in which the server HTML was emitted. By calling `useId`, you ensure that hydration will work, and the output will match between the server and the client.
182+
Artan sayaç kullanarak bunu garanti etmek çok zordur. İstemci bileşenlerinin hidratlanma sırası ile sunucu HTML'inin tarayıcıya gönderilme sırası eşleşmeyebilir. `useId`'yi çağırmak; hidratlamanın çalışacağından, sunucu ve istemci arasındaki çıktının özdeş olacağından emin olmanızı sağlar.
183183
184-
Inside React, `useId` is generated from the "parent path" of the calling component. This is why, if the client and the server tree are the same, the "parent path" will match up regardless of rendering order.
184+
React'ta `useId`'nin değeri, çağrıldığı bileşenin ağaç içindeki hiyerarşik yolundan (parent path) üretilir. Dolayısıyla sunucu ve istemci ağaçları aynıysa, ürettikleri değerler render sırasına bakılmaksızın eşleşecektir.
185185
186186
</DeepDive>
187187
188188
---
189189
190-
### Generating IDs for several related elements {/*generating-ids-for-several-related-elements*/}
190+
### Birkaç ilişkili element için kimlik üretmek {/*generating-ids-for-several-related-elements*/}
191191
192-
If you need to give IDs to multiple related elements, you can call `useId` to generate a shared prefix for them:
192+
Bir takım ilişkili elemente kimlik vermeniz gerekiyorsa, `useId`'yi çağırarak ürettiğiniz kimliği sonekler ile özelleştirebilirsiniz:
193193
194194
<Sandpack>
195195
@@ -200,10 +200,10 @@ export default function Form() {
200200
const id = useId();
201201
return (
202202
<form>
203-
<label htmlFor={id + '-firstName'}>First Name:</label>
203+
<label htmlFor={id + '-firstName'}>İsim:</label>
204204
<input id={id + '-firstName'} type="text" />
205205
<hr />
206-
<label htmlFor={id + '-lastName'}>Last Name:</label>
206+
<label htmlFor={id + '-lastName'}>Soyisim:</label>
207207
<input id={id + '-lastName'} type="text" />
208208
</form>
209209
);
@@ -216,13 +216,14 @@ input { margin: 5px; }
216216
217217
</Sandpack>
218218
219-
This lets you avoid calling `useId` for every single element that needs a unique ID.
219+
Bu kullanım, benzersiz kimliğe ihtiyaç duyan her bir element için `useId`'yi çağırmaktan kaçınmanızı sağlar.
220220
221221
---
222222
223-
### Specifying a shared prefix for all generated IDs {/*specifying-a-shared-prefix-for-all-generated-ids*/}
223+
### Üretilen tüm kimlikler için önek belirlemek {/*specifying-a-shared-prefix-for-all-generated-ids*/}
224224
225-
If you render multiple independent React applications on a single page, pass `identifierPrefix` as an option to your [`createRoot`](/reference/react-dom/client/createRoot#parameters) or [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) calls. This ensures that the IDs generated by the two different apps never clash because every identifier generated with `useId` will start with the distinct prefix you've specified.
225+
226+
Tek bir sayfada birden fazla bağımsız React uygulaması render ederseniz, [`createRoot`](/reference/react-dom/client/createRoot#parameters) veya [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) metodlarına iletebileceğiniz `identifierPrefix` parametresini kullanın. Bu sayede `useId` ile oluşturulan her bir kimlik benzersiz bir önek ile başlayacağından, iki farklı uygulama tarafından oluşturulan kimlikler asla çakışmaz.
226227
227228
<Sandpack>
228229
@@ -246,14 +247,14 @@ function PasswordField() {
246247
return (
247248
<>
248249
<label>
249-
Password:
250+
Şifre:
250251
<input
251252
type="password"
252253
aria-describedby={passwordHintId}
253254
/>
254255
</label>
255256
<p id={passwordHintId}>
256-
The password should contain at least 18 characters
257+
Şifre en az 18 karakter içermelidir
257258
</p>
258259
</>
259260
);
@@ -262,7 +263,7 @@ function PasswordField() {
262263
export default function App() {
263264
return (
264265
<>
265-
<h2>Choose password</h2>
266+
<h2>Şifreni seç</h2>
266267
<PasswordField />
267268
</>
268269
);

0 commit comments

Comments
 (0)