There’s a small breaking changes in this update, as we’re introducing a better
API to enter and leave rooms. If you’re calling client.enter()
or
client.leave()
in your application, or using our Zustand or Redux packages, we
recommend you read on.
You can upgrade to 1.5 by downloading the latest version of each Liveblocks package you’re using, for example in a React app:
Until now, the API to manually enter a Room using the client looked like the following:
These APIs will remain supported and unchanged, but starting with Liveblocks 1.5, there is a new preferred API, which we recommend you switch to:
We’ve changed this API to return a new “leave” function every time a room
reference is requested. This allows sharing the same room connection with two or
more parts of your application, without those parts competing for control of the
room connection. The room connection will only be terminated after every leave
function has been called.
This enables more advanced use cases such as supporting multiple RoomProvider
instances for the same room ID, in different parts of your application, or using
our React package for one part of your application, while using a Zustand store
for another.
If you’re using our Zustand package, there’s a breaking change—you no longer need to pass the room ID to leave the room:
If you’re using our Redux package, there’s a similar breaking change—you no longer need to pass the room ID to leave the room:
We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.