How to change checkbox value not only by clicking on that checkbox input but on the whole button that wraps input and span?
const statuses = ["Draft", "Pending", "Paid"];
const [checkedState, setCheckedState] = useState(
new Array(statuses.length).fill(false)
);
const handleCheckboxChange = (position: number) => {
const updatedCheckedState = checkedState.map((item, index) =>
index === position ? !item : item
);
setCheckedState(updatedCheckedState);
};
{statuses.map((status, index) => (
<button key={index}>
<input
type="checkbox"
onChange={() => handleCheckboxChange(index)}
/>
<span>{status}</span>
</button>
))}