I am using Switch Material UI Component to filter the between the tasks completed and not completed in my list.
See the demo codesandbox
I can switch the elements completed but the problem is that i can not switch back to the not completed when i toggle ( i can not reuse my entire tasks array to filter )
The method
const getCompleted = (e, value) => {
let result = [];
result = tasks.filter(({ completed }) => completed);
setFilteredData(result);
console.log(result);
};
The component
<FormControl component="fieldset">
<FormControlLabel
value="start"
control={<Switch onChange={getCompleted} color="primary" />}
label="Start"
labelPlacement="start"
/>
</FormControl>