Greetings everyone, i have a question regarding Ko...
# javascript
z
Greetings everyone, i have a question regarding Kotlin-React and websockets. In plain React it is (according to my research) common to instantiate a single WebSocket instance at the root of your application and then pass it down via props. But is there an alternative (Edit: idiomatic) way to share this single instance in Kotlin React? Like using a top level declaration or an object handling that connection? Thank you for your answers in advance!
✔️ 1
a
A top-level declaration sounds like a bad fit for React in general. I would always have something instantiated in a top-level component, where it can be bound to the mount/unmount lifecycle. Passing it (or some API wrapping it) down through the componentry makes testing a lot saner too.
✔️ 2
z
Ok, thanks for the advice. 👍