react-query-kit
react-query-kit copied to clipboard
What is the best practice for invalidating queries in react-query-kit
I generally use the approach in the code below.
import { queryClient } from "@sustable/system";
export const useDeleteUserMutation = createMutation({
mutationKey: ["corporate", "user", "delete"],
mutationFn: async (data: IDeleteUserRequest) => {
await agent.delete("/user/delete", { data });
},
onSuccess: () =>
queryClient.invalidateQueries({
queryKey: ["corporate", "user", "list"],
}),
});
This approach does not use useQueryClient()
hook and I just wanna know if this approach has any side effect. If there is a side effect, what can I do to prevent that side effect? Is middleware like approach a better solution for this? If it is, could we add this to documentation of react-query-kit
Thank in advance.