Not sure what you are intending exactly, but I'm guessing is that you have a list of objects which reflect a list on the page which can be checked. I suspect you want to have the state update when clicking on an element without updating the entire list?
What you did is okay and should work, but if you don't want the entire list to redraw, you should make a 'ListItem' react element, then let that manage it's own internal checked state, and expose a callback when this changes.
An example below:
const ListItem = ({name, defaultChecked, callback}) => {
const [checked, setChecked] = useState(defaultChecked);
const toggleChecked = () => {
setChecked(!checked)
callback(checked)
}
return <div>
<button onClick={() => toggleChecked()}>{checked}</button>
<div>{name}</div>
</div>
}
Naturally you'll update the HTML to make sense for your case. And remember this is just an option which internally managed the checked state, and there are cases where you don't want this and prefer to implement it as you have above.