React TutorialLesson 35Free preview
React Radio
This lesson is part of React · All levels
Summary
The radio button is used to select one option from several options. All the radios in a group must have the same name attribute, whereas the value of each option is differentiated by the value. In React, the selected status is determined by comparing the value of the state with the value of each radio.
Key points
- The same name grouped the radio so that only one was selected
- Value stores the value that the user will choose
- Checked calculated from the comparison of state with radio value
- OnChange keeps the latest options to the state
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.