score:3

Accepted answer

The useMutation hook returns some boolean variables you can use.

const mutation = useMutation(deleteInvoice, {
    onSuccess: () => {
      queryClient.invalidateQueries("invoices");
    },
  });

const removeInvoice = () => {
    mutation.mutate(id)
}

if (mutation.isSuccess) {
    return <Redirect to='/' />
}

return (
....
)

Related Query

More Query from same tag