Skip to content

Commit

Permalink
Ensure that waiting room cannot be rendered multiple times on the page
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Fosco committed Dec 13, 2023
1 parent 02e9a81 commit 3a91625
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/breakout-rooms/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ import { ErrorBoundary } from "./components/ErrorBoundary";

const App: React.FC = () => {
const { isFacilitator, breakout } = useBreakout();
const [waitingRoomRendered, setWaitingRoomRendered] = React.useState(false);

const areYouReady = isFacilitator || !breakout;

const renderWaitingRoom = () => {
if (!waitingRoomRendered) {
setWaitingRoomRendered(true);
}
};

return (
<ErrorBoundary>
<MiroProvider>
{areYouReady ? <BreakoutManager /> : <WaitingRoom />}
{areYouReady ? <BreakoutManager /> : null}
{!areYouReady && !waitingRoomRendered ? (
<WaitingRoom onRender={renderWaitingRoom} />
) : null}
</MiroProvider>
</ErrorBoundary>
);
Expand Down

0 comments on commit 3a91625

Please sign in to comment.