React TutorialLesson 34Free preview
React Checkbox
This lesson is part of React · All levels
Summary
The checkbox on React represents the boolean status, so its main attribute is checked and changes through onChange. The checkbox value is taken from the property e.target.checked, not e.target.value. Because it is boolean, the checkbox is very suitable for yes or no options in the state.
Key points
- Checked is the boolean value true or false
- OnChange read e.target.checked
- Controlled checkbox requires a boolean state
- Checked=false makes the box appear empty
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.