liveBook · Manning

Checked property

As explained in React Quickly, Second Edition

The checked property is a form-control property that reports whether a checkbox input is selected.

For checkboxes and radio buttons, the changing state is whether the control is selected, not its value. React represents that state with the boolean checked property. section 9.2.5

Store checkbox state in React

Keep the checkbox controlled by storing a Boolean in state and passing it to checked. Read the new Boolean from evt.target.checked in onChange: const [data, setData] = useState({ title: "", isUrgent: false }); const onChangeUrgent = (evt) => setData((oldData) => ({ ...oldData, isUrgent: evt.target.checked })); <input type="checkbox" checked={data.isUrgent} onChange={onChangeUrgent} /> The title uses evt.target.value, while the checkbox uses evt.target.checked. section 9.4 section 9.5

How React Quickly, Second Edition covers it

How deep it goes
Explains Boolean state, controlled rendering, and change-event reading without discussing browser internals.
Examples
Uses an urgent-task checkbox whose Boolean value is stored in a to-do item.
What it assumes
Assumes basic React state and event-handler usage while distinguishing checkbox state from text-input values.
What you can do after
Apply it via React state and onChange to build controlled checkbox forms.
How it connects
Connects checked property with controlled inputs, React state, radio buttons, and the onChange event handler.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of React Quickly, Second Edition. The section links point to the parts of the book it draws on.