I have an application retrieving a list of todos from this endpoint
I have built a CheckBoxDropDown
component to select the id of each todo
In the CheckBoxDropDown.js
component i am passing as prop the function onChange
const handleChange = (event) => {
const value = event.target.value;
setSelected(value);
onChange(value);
};
<Select
labelId="mutiple-select-label"
multiple
value={selected}
onChange={handleChange}
renderValue={(selected) => selected.join(", ")}
MenuProps={MenuProps}
>
In App.js
i am passing the data ( tasks ) to my component, everything works fine.
<CheckBoxDropDown onChange={handleFilterTasks} tasks={tasks} />
How can i filter in my handleFilterTasks
method the task or tasks id for any id i select in the dropdown ?
This is what i am trying to do but i can not get my result array with the filter data por id selected
const handleFilterTasks = (item, e) => {
const task = e
const userId = tasks[e]
const result = tasks.filter(val => val.id !== userId);
console.log(result);
// setFilteredData(task);
}
You can see the demo here