Skip to main content
Version: 6.4

useCancelling()

function useCancelling<E extends EndpointInterface & {
extend: (o: {
signal?: AbortSignal | undefined;
}) => any;
}>(endpoint: E, params: EndpointParam<E> | null): E

Builds an Endpoint that cancels fetch everytime params change

Aborts inflight request if the parameters change.

import { useCancelling } from '@rest-hooks/hooks';
import { useSuspense } from 'rest-hooks';

const CancelingUserList = useCancelling(UserList, { query });
const users = useSuspense(CancelingUserList, { query });

Part of @rest-hooks/hooks