Type Parameters
- TPath extends string
- TData = any
- TFormData = OnlyObject
- TExtraData = any
Returns {
mutation:
| {
context: unknown;
data: undefined;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: true;
isPaused: boolean;
isPending: false;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "idle";
submittedAt: number;
variables: undefined;
}
| {
context: unknown;
data: undefined;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: false;
isPaused: boolean;
isPending: true;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "pending";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
}
| {
context: unknown;
data: undefined;
error: CustomError;
failureCount: number;
failureReason: null | CustomError;
isError: true;
isIdle: false;
isPaused: boolean;
isPending: false;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "error";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
}
| {
context: unknown;
data: QueryResponse<TData>;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: false;
isPaused: boolean;
isPending: false;
isSuccess: true;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "success";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
};
update: ((__namedParameters: UpdateBaseVariables<TPath, TFormData, "one", TExtraData>) => Promise<void>);
}
An object with a single properties, update
and mutation
.
update
is a function to perform the update operation.
Accepts the ID, data, and params of the resource.
mutation
is result useMutation
without propery mutate
mutation:
| {
context: unknown;
data: undefined;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: true;
isPaused: boolean;
isPending: false;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "idle";
submittedAt: number;
variables: undefined;
}
| {
context: unknown;
data: undefined;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: false;
isPaused: boolean;
isPending: true;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "pending";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
}
| {
context: unknown;
data: undefined;
error: CustomError;
failureCount: number;
failureReason: null | CustomError;
isError: true;
isIdle: false;
isPaused: boolean;
isPending: false;
isSuccess: false;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "error";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
}
| {
context: unknown;
data: QueryResponse<TData>;
error: null;
failureCount: number;
failureReason: null | CustomError;
isError: false;
isIdle: false;
isPaused: boolean;
isPending: false;
isSuccess: true;
mutateAsync: UseMutateAsyncFunction<QueryResponse<TData>, CustomError, {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
}, unknown>;
reset: (() => void);
status: "success";
submittedAt: number;
variables: {
apiClientParams?: Partial<ApiProps>;
data: TFormData;
extraData?: TExtraData;
extraResources?: Resource<any>[];
id: string | number;
resource: Resource<TPath>;
};
}
- (__namedParameters): Promise<void>
Returns Promise<void>
A hook that helps you update a single resource.
The hook uses
useMutation
from@tanstack/react-query
under the hood, so it accepts all the same options. It performs an optimistic update by immediately applying the update to the cache before the update request is sent. If the update request fails, the previous state is restored in the cache.If the
undoable
mode is enabled, the hook allows the update to be undone within a certain period of time. If the undo action is not performed, the update will be applied permanently.Example