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
Every time your `ChatRoom`component re-renders, it passes the latest `roomId`and`serverUrl` to yourHook. 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.)
837
837
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*/}
839
839
840
840
<Wip>
841
841
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.
843
843
844
844
</Wip>
845
845
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:
}, [roomId, serverUrl, onReceiveMessage]); // ✅ All dependencies declared
896
+
}, [roomId, serverUrl, onReceiveMessage]); // ✅ Tüm bağımlılıklar bildirildi
897
897
}
898
898
```
899
899
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.
901
901
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)
}, [roomId, serverUrl]); // ✅ All dependencies declared
922
+
}, [roomId, serverUrl]); // ✅ Tüm bağımlılıklar bildirildi
923
923
}
924
924
```
925
925
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:
927
927
928
928
<Sandpack>
929
929
@@ -932,18 +932,18 @@ import { useState } from 'react';
0 commit comments