fix: rerender on name change

This commit is contained in:
Ayush
2023-10-08 08:39:37 +05:30
parent 86adc0eeff
commit 3af6498891
@@ -13,6 +13,8 @@ import { useEffect, useRef, useState } from "react";
type TPreviewType = "modal" | "fullwidth" | "email";
let surveyQuestionLengthTemp;
interface PreviewSurveyProps {
survey: TSurvey | Survey;
setActiveQuestionId: (id: string | null) => void;
@@ -60,6 +62,14 @@ export default function PreviewSurvey({
}
}, [activeQuestionId, survey.type, survey, setActiveQuestionId]);
useEffect(() => {
if (survey.questions.length !== surveyQuestionLengthTemp) {
resetQuestionProgress();
surveyQuestionLengthTemp = survey.questions.length;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [survey.questions.length]);
function resetQuestionProgress() {
let storePreviewMode = previewMode;
setPreviewMode("null");