lundi 4 octobre 2021

Best way to add and remove objects from array using custom checkboxes

How can i add and remove objects from array on checking and unchecking custom checkboxes ? and a trigger/flag to checkbox that is it checked or not ..!!

onClick function

const handleFilterValues = (meta_name, meta_value) => {
    const entry = { name: meta_name, value: meta_value };
    var data = [...dataArray];
    data.push(entry);
    setDataArray(data);
}
[0: {name: "meta_browser", value: "chrome"}
1: {name: "meta_browser", value: "firefox"}]



Aucun commentaire:

Enregistrer un commentaire