How to select a response among several responses in react

I am stuck on the selection of the different choices of answer I would like that when I click on a choice its background changes colors and if I click on another choice its background changes color and its first returns to its initial background please I need help
here is the link of the project: GitHub - rochelin-shikamaru/otaku-challenge

Without looking at your code, just on the theoretical…

You would need to keep track of the id of which one is selected. This could be in the component state, some lifted up state, redux state, context, whatever. You would set it when something is pressed and change it when something else is pressed and clear it if needed. This value would be passed into whatever is rendering your choices so each choice would know which CSS/class to use.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.