Skip to content

Commit

Permalink
fix: display quiz correct count on demo
Browse files Browse the repository at this point in the history
  • Loading branch information
a2937 committed Oct 13, 2024
1 parent 1e3d18c commit 785e818
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/quiz/quiz.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const QuizWithValidation = () => {

return (
<div>
{correctAnswerCount && <p>Correct answers: {correctAnswerCount}</p>}
{correctAnswerCount > -1 && (
<div aria-live="polite">
<p>Correct answers: {correctAnswerCount}</p>
</div>
)}
<Quiz questions={questions} disabled={disabled} />
<Spacer size="m" />
<Button onClick={handleSubmit}>Submit</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/quiz/use-quiz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useQuiz = <AnswerT extends number | string>({
}: Props<AnswerT>) => {
const [questions, setQuestions] =
useState<Question<AnswerT>[]>(initialQuestions);
const [correctAnswerCount, setCorrectAnswerCount] = useState(0);
const [correctAnswerCount, setCorrectAnswerCount] = useState(-1);

const questionsWithChangeHandling = questions.map((question, index) => ({
...question,
Expand Down

0 comments on commit 785e818

Please sign in to comment.