Skip to content

What is the best practice for invalidating queries in react-query-kit #62

Description

@inceenes10

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions