Skip to content

Commit 918db58

Browse files
committed
fix: cancel button breaking quiz
1 parent 260633b commit 918db58

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/mdx/Quiz.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const Quiz: FC<QuizProps> = (props: QuizProps) => {
8989
correctAnswers &&
9090
correctAnswers.indexOf(currentQuestionIndex) !== -1 &&
9191
quiz.questions[currentQuestionIndex].options[optionIndex].correct &&
92-
answers[currentQuestionIndex].includes(optionIndex)
92+
answers[currentQuestionIndex]?.includes(optionIndex)
9393
) {
9494
return 'green.500'
9595
}
@@ -162,6 +162,7 @@ const Quiz: FC<QuizProps> = (props: QuizProps) => {
162162
const cancelQuiz = () => {
163163
setAnswers({})
164164
setShowQuiz(false)
165+
setCorrectAnswers(null)
165166
setCurrentQuestionIndex(0)
166167
}
167168

0 commit comments

Comments
 (0)