Skip to content

Commit

Permalink
fix(react-native): unnecessary participant rerenders when using grid
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Aug 31, 2023
1 parent 120f866 commit 5d96170
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export const CallParticipantsGrid = ({
} = useTheme();
const { useRemoteParticipants, useParticipants } = useCallStateHooks();
const _remoteParticipants = useRemoteParticipants();
const allParticipants = useParticipants();
const remoteParticipants = useDebouncedValue(_remoteParticipants, 300); // we debounce the remote participants to avoid unnecessary rerenders that happen when participant tracks are all subscribed simultaneously
const _allParticipants = useParticipants();
// we debounce the participants arrays to avoid unnecessary rerenders that happen when participant tracks are all subscribed simultaneously
const remoteParticipants = useDebouncedValue(_remoteParticipants, 300);
const allParticipants = useDebouncedValue(_allParticipants, 300);

const showFloatingView =
remoteParticipants.length > 0 && remoteParticipants.length < 3;
Expand Down

0 comments on commit 5d96170

Please sign in to comment.