From 51dda679926fa315462f92554c55a1e831274170 Mon Sep 17 00:00:00 2001 From: Dhruwang Date: Sat, 5 Aug 2023 15:08:34 +0530 Subject: [PATCH] fixed invalid storedResponseValue issue --- apps/web/components/preview/MultipleChoiceMultiQuestion.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx b/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx index 6a69819dc4..939ffb82de 100644 --- a/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx +++ b/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx @@ -39,7 +39,8 @@ export default function MultipleChoiceMultiQuestion({ .map((choice) => choice.label); useEffect(() => { - const nonOtherSavedChoices = storedResponseValue?.filter((answer) => + if(Array.isArray(storedResponseValue)){ + const nonOtherSavedChoices = storedResponseValue?.filter((answer) => nonOtherChoiceLabels.includes(answer) ); const savedOtherSpecified = storedResponseValue?.find((answer) => !nonOtherChoiceLabels.includes(answer)); @@ -50,6 +51,7 @@ export default function MultipleChoiceMultiQuestion({ setOtherSpecified(savedOtherSpecified); setShowOther(true); } + } // eslint-disable-next-line react-hooks/exhaustive-deps }, [storedResponseValue, question.id]);