score:2

Accepted answer
const [selected, setSelected] = useState([]);
const attendCheck = ({ target: { name, value, id } }) => {
  if (!selected.includes(id)) {
    setSelected((prevSelected) => [...prevSelected, id]);
  } else {
    setSelected((prevSelected) =>
      prevSelected.filter((stdId) => stdId!== id)
    );
  }
} 

Related Query

More Query from same tag