Skip to content

Commit ee8b3fd

Browse files
committed
docs: translate custom hooks (20%)
1 parent b1f89b0 commit ee8b3fd

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/content/learn/reusing-logic-with-custom-hooks.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -264,34 +264,34 @@ function List({ items, shouldSort }) {
264264
// ...
265265
}
266266
```
267-
// TODO: Continue from here
268-
You should give `use` prefix to a function (and thus make it a Hook) if it uses at least one Hook inside of it:
267+
268+
Bir fonksiyon eğer bir ya da daha fazla Hook'u içeriyorsa, ona `use` ön eki vermelisiniz:
269269

270270
```js
271-
//Good: A Hook that uses other Hooks
271+
//İyi: Diğer Hook'ları kullanan bir Hook
272272
function useAuth() {
273273
return useContext(Auth);
274274
}
275275
```
276276

277-
Technically, this isn't enforced by React. In principle, you could make a Hook that doesn't call other Hooks. This is often confusing and limiting so it's best to avoid that pattern. However, there may be rare cases where it is helpful. For example, maybe your function doesn't use any Hooks right now, but you plan to add some Hook calls to it in the future. Then it makes sense to name it with the `use` prefix:
277+
Teknik olarak, bu React tarafından zorunlu kılınmıyor. Prensipte, başka Hook'ları çağırmayan bir Hook yapabilirsiniz. Bu genellikle kafa karıştırıcı ve limitleyicidir, bu yüzden bu örüntüden uzak durmak en iyisidir. Ancak, işe yarayacağı nadir durumlar bulunabilir. Örneğin, belki fonksiyonunu şu anda hiçbir Hook'u kullanmıyor, ancak gelecekte ona bazı Hook çağrıları eklemeyi düşünüyorsunuz. O zaman onu `use` ön eki ile adlandırmak mantıklı olur:
278278

279279
```js {3-4}
280-
//Good: A Hook that will likely use some other Hooks later
280+
//İyi: Gelecekte muhtemelen başka Hook'ları kullanacak bir Hook
281281
function useAuth() {
282-
// TODO: Replace with this line when authentication is implemented:
282+
// TODO: Authentication tamamlanınca bu satırı değiştir:
283283
// return useContext(Auth);
284284
return TEST_USER;
285285
}
286286
```
287287

288-
Then components won't be able to call it conditionally. This will become important when you actually add Hook calls inside. If you don't plan to use Hooks inside it (now or later), don't make it a Hook.
288+
Bu şekilde bileşenler onu koşullu olarak çağıramayacaktır. Bu, içine Hook çağrıları eklediğinizde önemli olacaktır. Eğer onun içinde Hook kullanmayı (şimdi ya da gelecekte) planlamıyorsanız, onu bir Hook yapmayın.
289289

290290
</DeepDive>
291291

292-
### Custom Hooks let you share stateful logic, not state itself {/*custom-hooks-let-you-share-stateful-logic-not-state-itself*/}
292+
### Özel Hook'lar stateli mantığı paylaşmanızı sağlar, state'in kendisini değil {/*custom-hooks-let-you-share-stateful-logic-not-state-itself*/}
293293

294-
In the earlier example, when you turned the network on and off, both components updated together. However, it's wrong to think that a single `isOnline` state variable is shared between them. Look at this code:
294+
Daha önceki bir örnekte, ağı açıp kapattığınızda, her iki bileşen de birlikte güncellendi. Ancak, onların arasında tek bir `isOnline` state değişkeninin paylaşıldığını düşünmek yanlış olur. Bu kodu inceleyin:
295295

296296
```js {2,7}
297297
function StatusBar() {
@@ -305,7 +305,7 @@ function SaveButton() {
305305
}
306306
```
307307

308-
It works the same way as before you extracted the duplication:
308+
Bu, tekrarı çıkartmanızdan önceki hali gibi çalışır:
309309

310310
```js {2-5,10-13}
311311
function StatusBar() {
@@ -325,9 +325,9 @@ function SaveButton() {
325325
}
326326
```
327327

328-
These are two completely independent state variables and Effects! They happened to have the same value at the same time because you synchronized them with the same external value (whether the network is on).
328+
Bunlar tamamen bağımsız iki state değişkenleri ve efektlerdir! Onlar rastlantısal olarak aynı anda aynı değere sahip oldular çünkü onları aynı harici değerle (ağın açık olup olmaması) senkronize ettiniz.
329329

330-
To better illustrate this, we'll need a different example. Consider this `Form` component:
330+
Bunu daha iyi canlandırabilmek adına, farklı bir örnek kullanacağız. Bu `Form` bileşenini ele alın:
331331

332332
<Sandpack>
333333

@@ -349,14 +349,14 @@ export default function Form() {
349349
return (
350350
<>
351351
<label>
352-
First name:
352+
İsim:
353353
<input value={firstName} onChange={handleFirstNameChange} />
354354
</label>
355355
<label>
356-
Last name:
356+
Soyisim:
357357
<input value={lastName} onChange={handleLastNameChange} />
358358
</label>
359-
<p><b>Good morning, {firstName} {lastName}.</b></p>
359+
<p><b>Günaydınlar, {firstName} {lastName}.</b></p>
360360
</>
361361
);
362362
}
@@ -369,13 +369,13 @@ input { margin-left: 10px; }
369369

370370
</Sandpack>
371371

372-
There's some repetitive logic for each form field:
372+
Her form alanı için tekrarlayan bir mantık var:
373373

374-
1. There's a piece of state (`firstName` and `lastName`).
375-
1. There's a change handler (`handleFirstNameChange` and `handleLastNameChange`).
376-
1. There's a piece of JSX that specifies the `value` and `onChange` attributes for that input.
374+
1. Bir parça state bulunuyor (`firstName` ve `lastName`).
375+
2. Bir değişim yöneticisi bulunuyor (`handleFirstNameChange` ve `handleLastNameChange`).
376+
3. O girdi için `value` ve `onChange` özniteliklerini belirleyen bir parça JSX bulunuyor.
377377

378-
You can extract the repetitive logic into this `useFormInput` custom Hook:
378+
Bu tekrarlayan mantığı `useFormInput` özel Hook'una çıkartabilirsiniz:
379379

380380
<Sandpack>
381381

@@ -389,14 +389,14 @@ export default function Form() {
389389
return (
390390
<>
391391
<label>
392-
First name:
392+
İsim:
393393
<input {...firstNameProps} />
394394
</label>
395395
<label>
396-
Last name:
396+
Soyisim:
397397
<input {...lastNameProps} />
398398
</label>
399-
<p><b>Good morning, {firstNameProps.value} {lastNameProps.value}.</b></p>
399+
<p><b>Günaydınlar, {firstNameProps.value} {lastNameProps.value}.</b></p>
400400
</>
401401
);
402402
}
@@ -428,9 +428,9 @@ input { margin-left: 10px; }
428428

429429
</Sandpack>
430430

431-
Notice that it only declares *one* state variable called `value`.
431+
`value` adında sadece *bir* state değişkeni oluşturduğuna dikkat edin.
432432

433-
However, the `Form` component calls `useFormInput` *two times:*
433+
Yine de, `Form` bileşeni `useFormInput`'u *iki kez* çağırıyor:
434434

435435
```js
436436
function Form() {
@@ -439,17 +439,17 @@ function Form() {
439439
// ...
440440
```
441441
442-
This is why it works like declaring two separate state variables!
442+
Bu yüzden iki ayrı state değişkeni oluşturmuş gibi çalışıyor!
443443
444-
**Custom Hooks let you share *stateful logic* but not *state itself.* Each call to a Hook is completely independent from every other call to the same Hook.** This is why the two sandboxes above are completely equivalent. If you'd like, scroll back up and compare them. The behavior before and after extracting a custom Hook is identical.
444+
**Özel Hook'lar sizin *stateli mantık* paylaşmanıza olanak sağlar, *state'in kendinisi*ni değil. Bir Hook'a yapılan her çağrı aynı Hook'a yapılan tüm çağrılardan bağımsızdır.** Bu nedenle yukarıdaki iki kod alanı tamamen eşdeğerdir. İsterseniz, yukarı kayarak onları karşılaştırın. Özel bir Hook çıkartmadan önceki ve sonraki davranış tamamen aynıdır.
445445
446-
When you need to share the state itself between multiple components, [lift it up and pass it down](/learn/sharing-state-between-components) instead.
446+
State'i birden fazla bileşen arasında paylaşmak istediğinizde, bunun yerine onu [yukarı kaldırın ve aşağı geçirin](/learn/sharing-state-between-components).
447447
448-
## Passing reactive values between Hooks {/*passing-reactive-values-between-hooks*/}
448+
## Hook'lar arasında reaktif değerler geçirme {/*passing-reactive-values-between-hooks*/}
449449
450-
The code inside your custom Hooks will re-run during every re-render of your component. This is why, like components, custom Hooks [need to be pure.](/learn/keeping-components-pure) Think of custom Hooks' code as part of your component's body!
450+
Özel Hook'larınızın içindeki kod, bileşeniniz her yeniden render edildiğinde yeniden yürütülecektir. Bu nedenle, bileşenler gibi, özel Hook'lar da [saf olmalıdır.](/learn/keeping-components-pure) Özel Hook'larınızın kodunu bileşeninizin bir parçası olarak düşünün!
451451
452-
Because custom Hooks re-render together with your component, they always receive the latest props and state. To see what this means, consider this chat room example. Change the server URL or the chat room:
452+
Özel Hook'lar bileşeninizle birlikte yeniden render edildiğinden, her zaman en son prop'ları ve state'i alırlar. Bunun ne anlama geldiğini görmek için, bu sohbet odası örneğini ele alın. Sunucu URL'sini veya sohbet odasını değiştirin:
453453
454454
<Sandpack>
455455
@@ -462,14 +462,14 @@ export default function App() {
462462
return (
463463
<>
464464
<label>
465-
Choose the chat room:{' '}
465+
Sohbet odasını seçin:{' '}
466466
<select
467467
value={roomId}
468468
onChange={e => setRoomId(e.target.value)}
469469
>
470-
<option value="general">general</option>
471-
<option value="travel">travel</option>
472-
<option value="music">music</option>
470+
<option value="general">genel</option>
471+
<option value="travel">seyahat</option>
472+
<option value="music">müzik</option>
473473
</select>
474474
</label>
475475
<hr />
@@ -496,7 +496,7 @@ export default function ChatRoom({ roomId }) {
496496
};
497497
const connection = createConnection(options);
498498
connection.on('message', (msg) => {
499-
showNotification('New message: ' + msg);
499+
showNotification('Yeni mesaj: ' + msg);
500500
});
501501
connection.connect();
502502
return () => connection.disconnect();
@@ -505,15 +505,15 @@ export default function ChatRoom({ roomId }) {
505505
return (
506506
<>
507507
<label>
508-
Server URL:
508+
Sunucu URL'i:
509509
<input value={serverUrl} onChange={e => setServerUrl(e.target.value)} />
510510
</label>
511-
<h1>Welcome to the {roomId} room!</h1>
511+
<h1>{roomId} odasına hoşgeldiniz!</h1>
512512
</>
513513
);
514514
}
515515
```
516-
516+
// TODO: continue from here
517517
```js chat.js
518518
export function createConnection({ serverUrl, roomId }) {
519519
// A real implementation would actually connect to the server

0 commit comments

Comments
 (0)