Open
Description
Hi, I hope this is not a duplicate, I didn't find anything related to it though.
I need to have two different connections and send data to them simultaneously.
I tried to do that by useMemo but eventually react Hooks I can't use inside other methods ;)
const connections = useMemo(() => {
return socketArray.map((socketURL) => {
const { sendMessage, lastMessage, readyState } = useWebSocket(socketURL, {
onOpen: () => console.log(`Connected to ${socketURL}`),
onClose: () => console.log(`Closed connection to ${socketURL}`),
onError: (error) => console.error(`WebSocket error on ${socketURL}`, error),
});
return { sendMessage, lastMessage, readyState, socketURL };
});
}, [socketArray]);
I tried to create a custom hook, but the same result..
Thanks in advance for your feedback 🙏
Metadata
Metadata
Assignees
Labels
No labels