Recall & Review
beginner
How do you track the state of a checkbox in React?
You use the
useState hook to store a boolean value representing whether the checkbox is checked or not. The checkbox's checked attribute is set from this state, and the onChange handler updates the state when the user clicks.Click to reveal answer
intermediate
What is the difference between controlled and uncontrolled checkboxes in React?
Controlled checkboxes have their checked state managed by React state, so React controls their value. Uncontrolled checkboxes manage their own state internally, and you access their value using refs or form submission.
Click to reveal answer
intermediate
How do you handle multiple checkboxes in React when users can select many options?
You store the selected options in an array state. When a checkbox is checked, you add its value to the array. When unchecked, you remove it. The
checked attribute checks if the value is in the array.Click to reveal answer
beginner
How do radio buttons differ from checkboxes in React handling?
Radio buttons allow only one selection in a group. You store a single value in state representing the selected option. Each radio button's
checked attribute compares its value to the state value.Click to reveal answer
beginner
Why is it important to use the
name attribute on radio buttons?The
name attribute groups radio buttons so the browser knows they belong together. This ensures only one radio button in the group can be selected at a time and improves accessibility.Click to reveal answer
Which React hook is commonly used to manage checkbox state?
✗ Incorrect
useState is used to store and update the checkbox's checked state.
How do you represent multiple selected checkboxes in React state?
✗ Incorrect
An array holds all selected checkbox values for multiple selections.
What attribute must radio buttons share to be grouped correctly?
✗ Incorrect
The name attribute groups radio buttons so only one can be selected.
In React, how do you update the state when a checkbox is clicked?
✗ Incorrect
The onChange handler updates the React state when the checkbox changes.
What happens if you don't control a checkbox in React?
✗ Incorrect
Without controlling it, the checkbox manages its own state internally.
Explain how to handle a single checkbox in React using state.
Think about how you track if the box is checked or not.
You got /4 concepts.
Describe how to manage a group of radio buttons in React so only one can be selected.
Remember radio buttons work like a team where only one can win.
You got /4 concepts.