From fc15d2c3bd66ec5d557e73d9529a2a9af8c623b3 Mon Sep 17 00:00:00 2001 From: "C. Fuhrman" Date: Fri, 21 Mar 2025 11:08:21 -0400 Subject: [PATCH] refactor --- .../TrueFalseQuestionDisplay.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx index 3409f47..717cdbe 100644 --- a/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx @@ -17,6 +17,15 @@ const TrueFalseQuestionDisplay: React.FC = (props) => { const { question, showAnswer, handleOnSubmitAnswer, passedAnswer } = props; + const [answer, setAnswer] = useState(() => { + + if (passedAnswer && (passedAnswer[0] === true || passedAnswer[0] === false)) { + return passedAnswer[0]; + } + + return undefined; + }); + let disableButton = false; if (handleOnSubmitAnswer === undefined) { disableButton = true; @@ -31,15 +40,6 @@ const TrueFalseQuestionDisplay: React.FC = (props) => { } }, [passedAnswer, question.id]); - const [answer, setAnswer] = useState(() => { - - if (passedAnswer && (passedAnswer[0] === true || passedAnswer[0] === false)) { - return passedAnswer[0]; - } - - return undefined; - }); - const handleOnClickAnswer = (choice: boolean) => { setAnswer(choice); };