mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-25 01:09:23 -05:00
fix: rerender on name change
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user