1
1
12332112020-10-20 16:05:29
React
1233211, 2020-10-20 16:05:29

How to select all checkboxes in react?

There is a page with checkboxes that have name={'names'} and onChange={handleClickCheckbox}.

This is how I collect data from checkboxes

const [names, setNames] = useState([]);

const handleClickCheckbox = (e) => {
    const formData = new FormData(e.currentTarget.form);
    const names = formData.getAll('names');
    setNames(names);
}


You need to create another checkbox, when you click on it, you need to select all checkboxes that have name='names'.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-10-20
@firedragon

Either a binding, or choose from the house by the filter and draw them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question