Closed SaremS closed 2 years ago
This is expected. useWebSocket
returns an object -- see doc. You are destructuring that object whenever you write const { sendMessage, lastMessage, readyState } = useWebSocket(socketUrl);
. This means the names within the {}
are keys that exist in the returned object. You can rename those in your destructure by { sendMessage: sendMessage2 }
.
More Info:
Thanks @koralarts
Hi,
is this intended:
const { sendMessage, lastMessage, readyState } = useWebSocket(socketUrl);
is working fine, but
const { sendMessage2, lastMessage2, readyState2 } = useWebSocket(socketUrl);
results in
lastMessage2===undefined
Thanks!