Replies: 2 comments
-
If you have fetched the list data on the client, use normal techniques for filtering it client-side. For example: const { data : users } = useGetUsersQuery();
const [filterName, setFilterName] = useState('');
const filteredUsers = useMemo(() => {
if (!filterName) {
return users;
}
return users.filter(user => user.name.includes(filterName));
}, [users, filterName]);
// render filtered users list here |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can use manual cache updates to delete that data and omit the tags so no automatic refetch happens - usually this doesn't really make a lot of difference for the backend though, and you will have to write and maintain additional code for it. From that perspective, I would usually recommend to stick with refetching instead of doing manual updates. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I started learning RTKQuery and perceived that for each change that I made to my data, RTKQuery would, for example, refetch the data for me. For example, I have a list of users and I execute one mutation for deleting one user, if I set up the tags correctly it will run the delete mutation and after that run a get request for fetching the new data without the user that I deleted.
My question is if I can, for example, when receiving an ok from my backend for the user deletion, filter the user list that I have on the application, instead of requesting a new set of data. Or does it is really supposed to happen and it is a give-earn situation where I increase my backend flow to have the most trusted set of data in my application?
Beta Was this translation helpful? Give feedback.
All reactions