diff --git a/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx index 95856e9687..8b4b0b770c 100644 --- a/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/VideoLayouts/GridLayout.tsx @@ -79,8 +79,8 @@ export const GridLayout = ({ }; useEffect(() => { - if (mainPage !== 0 || pageSize === 0) { - setSortedPeers(updatedPeers); + if (mainPage !== 0) { + peersSorter.stop(); return; } peersSorter.setPeersAndTilesPerPage({ @@ -88,6 +88,9 @@ export const GridLayout = ({ tilesPerPage: pageSize, }); peersSorter.onUpdate(setSortedPeers); + return () => { + peersSorter.stop(); + }; }, [mainPage, peersSorter, updatedPeers, pageSize]); if (peerSharing) {