I have a todo list fetching this endpoint
I have implemented some filters
- Search for title
- Toggling the todos completed and not
- Multiple select filters for id
I am now implementing the reset filters, which is refetching the todos list, this the method resetFilters
const resetFilters = () => {
const fetchPosts = async () => {
setLoading(true);
const res = await axios.get(
"https://jsonplaceholder.typicode.com/todos/"
);
setIsCompleted(null);
setSearchValue("");
setTasks(res.data);
setFilteredData(res.data);
setLoading(false);
};
fetchPosts();
};
The reset filter method works fine except from not cancelling the text that i have for example put in the search input, switched the toggle back or removing the id number from the Multiple select in the filters column
How can i clear all these infos out in my method resetFilters
?
I have reproduced the demo here