Skip to content

Commit f002a0d

Browse files
committed
docs: translate custom hooks (40%)
1 parent 14a87d6 commit f002a0d

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ export default function App() {
462462
return (
463463
<>
464464
<label>
465-
Sohbet odasını seçin:{' '}
465+
Sohbet odasını seçiniz:{' '}
466466
<select
467467
value={roomId}
468468
onChange={e => setRoomId(e.target.value)}
@@ -658,7 +658,7 @@ export default function App() {
658658
return (
659659
<>
660660
<label>
661-
Sohbet odasını seçin:{' '}
661+
Sohbet odasını seçiniz:{' '}
662662
<select
663663
value={roomId}
664664
onChange={e => setRoomId(e.target.value)}
@@ -806,8 +806,8 @@ button { margin-left: 10px; }
806806
```
807807
808808
</Sandpack>
809-
// TODO: Continue from here
810-
Notice how you're taking the return value of one Hook:
809+
810+
Bir Hook'un dönüş değerini alıp:
811811

812812
```js {2}
813813
export default function ChatRoom({ roomId }) {
@@ -820,7 +820,7 @@ export default function ChatRoom({ roomId }) {
820820
// ...
821821
```
822822

823-
and pass it as an input to another Hook:
823+
başka bir Hook'a girdi olarak nasıl verdiğinizi farkedin:
824824
825825
```js {6}
826826
export default function ChatRoom({ roomId }) {
@@ -833,17 +833,17 @@ export default function ChatRoom({ roomId }) {
833833
// ...
834834
```
835835
836-
Every time your `ChatRoom` component re-renders, it passes the latest `roomId` and `serverUrl` to your Hook. This is why your Effect re-connects to the chat whenever their values are different after a re-render. (If you ever worked with audio or video processing software, chaining Hooks like this might remind you of chaining visual or audio effects. It's as if the output of `useState` "feeds into" the input of the `useChatRoom`.)
836+
`ChatRoom` bileşeniniz her yeniden render edildiğinde, `roomId` ve `serverUrl`'in son hallerini Hook'unuza verir. Bu, bir yeniden render'dan sonra değerleri her değiştikten sonra Efekt'inizin sohbete yeniden bağlanmasının nedenidir. (Eğer önceden ses ya da video işleme yazılımı ile uğraştıysanız, Hook'ları bu şekilde zincirlemek size görsel ya da ses efektlerini zincirlemeyi hatırlatabilir. Adeta `useState`'in çıktısı `useChatRoom`'un girdisine "besleniyor" gibi.)
837837
838-
### Passing event handlers to custom Hooks {/*passing-event-handlers-to-custom-hooks*/}
838+
### Olay yöneticilerini özel Hook'lara geçirme {/*passing-event-handlers-to-custom-hooks*/}
839839
840840
<Wip>
841841
842-
This section describes an **experimental API that has not yet been released** in a stable version of React.
842+
Bu bölüm **henüz kararlı bir sürümde yayınlanmamış olan deneysel bir API'yi** açıklar.
843843
844844
</Wip>
845845
846-
As you start using `useChatRoom` in more components, you might want to let components customize its behavior. For example, currently, the logic for what to do when a message arrives is hardcoded inside the Hook:
846+
`useChatRoom`'u daha fazla bileşende kullanmaya başladıkça, bileşenlerin onun davranışını özelleştirmesine izin vermek isteyebilirsiniz. Örneğin, şu anda, bir mesaj geldiğinde ne yapılacağının mantığı Hook'un içine sabit kodlanmış durumda:
847847
848848
```js {9-11}
849849
export function useChatRoom({ serverUrl, roomId }) {
@@ -855,14 +855,14 @@ export function useChatRoom({ serverUrl, roomId }) {
855855
const connection = createConnection(options);
856856
connection.connect();
857857
connection.on('message', (msg) => {
858-
showNotification('New message: ' + msg);
858+
showNotification('Yeni mesaj: ' + msg);
859859
});
860860
return () => connection.disconnect();
861861
}, [roomId, serverUrl]);
862862
}
863863
```
864864
865-
Let's say you want to move this logic back to your component:
865+
Diyelim ki bu mantığı bileşeninize geri taşımak istiyorsunuz:
866866
867867
```js {7-9}
868868
export default function ChatRoom({ roomId }) {
@@ -872,13 +872,13 @@ export default function ChatRoom({ roomId }) {
872872
roomId: roomId,
873873
serverUrl: serverUrl,
874874
onReceiveMessage(msg) {
875-
showNotification('New message: ' + msg);
875+
showNotification('Yeni mesaj: ' + msg);
876876
}
877877
});
878878
// ...
879879
```
880880
881-
To make this work, change your custom Hook to take `onReceiveMessage` as one of its named options:
881+
Bunun çalışmasını sağlamak için, özel Hook'unuzu adlandırılmış seçeneklerinden biri olarak `onReceiveMessage`'ı alacak şekilde değiştirin:
882882
883883
```js {1,10,13}
884884
export function useChatRoom({ serverUrl, roomId, onReceiveMessage }) {
@@ -893,13 +893,13 @@ export function useChatRoom({ serverUrl, roomId, onReceiveMessage }) {
893893
onReceiveMessage(msg);
894894
});
895895
return () => connection.disconnect();
896-
}, [roomId, serverUrl, onReceiveMessage]); // ✅ All dependencies declared
896+
}, [roomId, serverUrl, onReceiveMessage]); //Tüm bağımlılıklar bildirildi
897897
}
898898
```
899899
900-
This will work, but there's one more improvement you can do when your custom Hook accepts event handlers.
900+
Bu çalışacaktır, ancak özel Hook'unuz olay yöneticilerini kabul ediyorsa yapabileceğiniz bir geliştirme daha var.
901901
902-
Adding a dependency on `onReceiveMessage` is not ideal because it will cause the chat to re-connect every time the component re-renders. [Wrap this event handler into an Effect Event to remove it from the dependencies:](/learn/removing-effect-dependencies#wrapping-an-event-handler-from-the-props)
902+
`onReceiveMessage`'a bir bağımlılık eklemek ideal değildir çünkü bileşen her yeniden render edildiğinde sohbetin yeniden bağlanmasına neden olacaktır. [Bu olay yöneticisini bağımlılıklardan çıkartmak için bir Efekt Olayı'na sarın:](/learn/removing-effect-dependencies#wrapping-an-event-handler-from-the-props)
903903
904904
```js {1,4,5,15,18}
905905
import { useEffect, useEffectEvent } from 'react';
@@ -919,11 +919,11 @@ export function useChatRoom({ serverUrl, roomId, onReceiveMessage }) {
919919
onMessage(msg);
920920
});
921921
return () => connection.disconnect();
922-
}, [roomId, serverUrl]); // ✅ All dependencies declared
922+
}, [roomId, serverUrl]); //Tüm bağımlılıklar bildirildi
923923
}
924924
```
925925
926-
Now the chat won't re-connect every time that the `ChatRoom` component re-renders. Here is a fully working demo of passing an event handler to a custom Hook that you can play with:
926+
Şimdi sohbet, `ChatRoom` bileşeni her yeniden render edildiğinde yeniden bağlanmayacaktır. Burada özel bir Hook'a bir olay yöneticisi geçirmekle ilgili oynayabileceğiniz tamamen çalışan bir demo var:
927927
928928
<Sandpack>
929929
@@ -932,18 +932,18 @@ import { useState } from 'react';
932932
import ChatRoom from './ChatRoom.js';
933933

934934
export default function App() {
935-
const [roomId, setRoomId] = useState('general');
935+
const [roomId, setRoomId] = useState('genel');
936936
return (
937937
<>
938938
<label>
939-
Choose the chat room:{' '}
939+
Sohbet odasını seçiniz:{' '}
940940
<select
941941
value={roomId}
942942
onChange={e => setRoomId(e.target.value)}
943943
>
944-
<option value="general">general</option>
945-
<option value="travel">travel</option>
946-
<option value="music">music</option>
944+
<option value="genel">genel</option>
945+
<option value="seyahat">seyahat</option>
946+
<option value="müzik">müzik</option>
947947
</select>
948948
</label>
949949
<hr />
@@ -967,17 +967,17 @@ export default function ChatRoom({ roomId }) {
967967
roomId: roomId,
968968
serverUrl: serverUrl,
969969
onReceiveMessage(msg) {
970-
showNotification('New message: ' + msg);
970+
showNotification('Yeni mesaj: ' + msg);
971971
}
972972
});
973973

974974
return (
975975
<>
976976
<label>
977-
Server URL:
977+
Sunucu URL'i:
978978
<input value={serverUrl} onChange={e => setServerUrl(e.target.value)} />
979979
</label>
980-
<h1>Welcome to the {roomId} room!</h1>
980+
<h1>{roomId} odasına hoşgeldiniz!</h1>
981981
</>
982982
);
983983
}

0 commit comments

Comments
 (0)