Hi LiveKit, I have some issues when connect to roo...
# helpdesk
f
Hi LiveKit, I have some issues when connect to room in React.
Copy code
const roomState = useRoom(roomOptions);
useEffect(() => {
    console.log('live kit useeffect');
    roomState.connect(url, token, connectOptions).then((room) => {
      console.log('room', room);
      if (!room) {
        return;
      }
      if (onConnected && room.state === ConnectionState.Connected) {
        onConnected(room);
      } 
    });

    return () => {
      if (roomState.connectionState !== ConnectionState.Disconnected) {
        roomState.room?.disconnect();
      }
    };
  }, []);