Starting in version 3.0.0, The useRoomConnection hook does not automatically join the room when initialized. It's required to manually call the joinRoom() function. This gives you as the developer more control of the lifecycle of the room connection. It's still possible to auto-join, but it requires some additional code. This code snippet mimicks the old behaviour, and auto-joins when the component is mounted.
From version 3, the useRoomConnection.components field is deprecated. It's no longer needed to bind components to the room connection, since we have the provider. The only change required is to import components directly from the library, instead of getting them from the hook.
This is an example of rendering a VideoView in version 2.
import { useRoomConnection } from"@whereby.com/browser-sdk/react";functionMyVideoApp( { roomUrl, localStream }) {// The components field here is now deprecated.const { state,actions,components } =useRoomConnection("<room_url>" { localMediaOptions: { audio:true, video:true, } } );const { connectionState,remoteParticipants } = state;const { joinRoom,leaveRoom } = actions;// This is the old way of getting the VideoView componentconst { VideoView } = components;React.useEffect(() => {joinRoom();return () =>leaveRoom(); }, []);return <divclassName="videoGrid"> { /* Render any UI, making use of state */ } { remoteParticipants.map((p) => ( <VideoViewkey={p.id} stream={p.stream} /> )) } </div>;}
In version 3, the code will look like this instead