TanStackT
TanStack2y ago
4 replies
thick-teal

How does one use the abort signal in combination with tanstack-query

Say I have the following route:

export const orderQueryOptions = (orderId: string) =>
    queryOptions({
        queryKey: ["order", { orderId }],
        queryFn: ({ signal }) =>
            api.get(`api/v1/orders/${orderId}`, { signal }).json<Order>(),
    });

export const Route = createFileRoute("/_authenticated/orders/$id")({
    component: ShowOrder,
    loader: ({ context, params }) =>
        context.queryClient.ensureQueryData(orderQueryOptions(params.id)),
});


How do I use the abort signal in both the
loader
and the
queryFn
Was this page helpful?