From b46690d63e2383a70535603fa9298daa1a8a8d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20La=20Scala?= Date: Tue, 18 Jun 2024 15:31:14 +0200 Subject: [PATCH] fix: check backend data is defined --- src/modules/question-view/QuestionView.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/question-view/QuestionView.tsx b/src/modules/question-view/QuestionView.tsx index 4d013765..13a93bce 100644 --- a/src/modules/question-view/QuestionView.tsx +++ b/src/modules/question-view/QuestionView.tsx @@ -56,7 +56,12 @@ const QuestionView = (): JSX.Element => { // Update the answer if the stored value change useEffect(() => { - if (status === 'success' && answer.length === 0 && !isInit) { + if ( + status === 'success' && + answer.length === 0 && + !isInit && + typeof userAnswer !== 'undefined' + ) { setAnswer(userAnswer?.answer ?? ''); setIsInit(true); }