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
Hi, im trying to use this library with a React context, according to the description unless the component unmounts the library not closing the connections
in my case the connections being kept open, or new ones being created when context value changes. there is no way for close unwanted socket connections
exportconstConversationProvider=({
conversationId,
children,}: ConversationProviderProps)=>{const[selectedConversationId,setSelectedConversationId]=useState(conversationId||"");constwsUrl=useMemo(()=>{if(!selectedConversationId)returnnull;return`wss://example.com/conversation/${selectedConversationId}`;},[selectedConversationId]);consthandleWsMessage=useCallback((e: MessageEvent)=>{console.log("Message received:",e.data);// Handle WebSocket messages here},[]);useWebSocket(wsUrl,{onMessage: handleWsMessage,retryOnError: true,},!!selectedConversationId// Determines whether the WebSocket should connect);constcontextValue=useMemo(()=>({
selectedConversationId,
setSelectedConversationId,}),[selectedConversationId]);return(<ConversationContext.Providervalue={contextValue}>{children}</ConversationContext.Provider>);};
The text was updated successfully, but these errors were encountered:
Hi, im trying to use this library with a React context, according to the description unless the component unmounts the library not closing the connections
in my case the connections being kept open, or new ones being created when context value changes. there is no way for close unwanted socket connections
The text was updated successfully, but these errors were encountered: