From 0e313f1db6f730b2a874e17f25103e6e73e39c87 Mon Sep 17 00:00:00 2001 From: KaustubhKumar05 Date: Wed, 15 May 2024 14:18:13 +0530 Subject: [PATCH] fix: ref to prevent multiple calls --- .../src/Prebuilt/components/Polls/Voting/Voting.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/Voting.tsx b/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/Voting.tsx index 466d4573b6..ebbc851dd6 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/Voting.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/Voting.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; import { selectPeerNameByID, selectPermissions, @@ -26,11 +26,13 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v const { setPollView } = usePollViewState(); // Sets view - linear or vertical, toggles timer indicator const showSingleView = poll?.type === 'quiz' && poll.state === 'started'; + const fetchedResponses = useRef(false); useEffect(() => { const getResponses = async () => { - if (poll && actions.interactivityCenter) { + if (poll && actions.interactivityCenter && !fetchedResponses.current) { await actions.interactivityCenter.getPollResponses(poll, true); + fetchedResponses.current = true; } }; getResponses();