Hice un enlace de reacción para devolver el cliente a esta biblioteca y, en este enlace, también estoy conectando al usuario.
useEffect((): any => { async function getSub() { const { data: { createSupportChatSubscription }, } = await getSubscription(); return createSupportChatSubscription.subscription; } getSub().then(async (res: ISubscription) => { const chatClient = StreamChat.getInstance(process.env.REACT_APP_STREAM_ID as string); await chatClient.connectUser( { id: currentUser.id, name: currentUser.name }, res.token.token ); setChannelResponse({ channelId: res.channelId, channelType: res.channelType, }); setClient(chatClient); }); return () => client?.disconnectUser(); }, [getSubscription, client, currentUser.id, currentUser.name, userId]);cuando uso este gancho, tiendo a recibir esta advertencia:
Consecutive calls to connectUser is detected, ideally you should only call this function once in your app. Estoy tratando de ver si el cliente de chat tiene algo para verificar si hay una conexión para no tener que llamar constantemente a connectUser .