spotty-amberS
Refine3y ago
25 replies
spotty-amber

How to invalidate a custom query of `useCustom`?

I want to invalidate a custom query that I have fetched using a useCustom hook based on a useDrawerForm successful mutation.

For example: I have a custom query as

const {
        data, refetch, isLoading
    } = useCustom({
        url: `${apiUrl}/custom-endpoint/`,
        method: 'get',
    })

And my drawer form as

const {
        formProps,
        drawerProps,
        show,
        saveButtonProps,
        id,
        close,
        queryResult
        onFinish
    } = useDrawerForm<IReservation>({
        action: 'edit',
        resource,
        id: reservationId,
        redirect: false,
        onMutationSuccess: () => {
            navigateToPayment("reservations/payment", reservationId);
            // <============== how can I invalidate the above custom query here?
        }
    });
Was this page helpful?