Step 2: State and instant feedback
Now make it interactive. useState(null) remembers which option the learner picked. Once selected is not null the question is answered: the buttons are disabled, the correct one turns green and a wrong pick turns red. Notice the colours are computed during render from selected and question.answer, not stored separately.
Examplereact
Click an answer. The message uses role="status" so screen readers announce "Correct!" or "Not quite." Also note that colour is not the only signal: the message says it in words, which matters for colour-blind users.
Quick check
Why are the green and red styles not stored in state?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.