Hacker News new | ask | show | jobs
by talkingtab 1176 days ago
But then again, you might need an effect. The behind the scenes (or behind the hooks) complexity that react adds in order to the make DOM thing work then makes it difficult when you do need an effect. Things like WebRTC or sockets or some such. useRef? useState? I have found this to be extremely difficult. If someone knows a good resource for doing things like this in React (and not a one page file, but with multiple components etc) I would appreciate knowing about it.
2 comments

I'd say pull that logic out of your components and put it in some central place like an XState machine exposed to your components through Context.
That's the case for useSyncExternalStore.