query-harbor
Version:
A React Query utility package for efficient data fetching and caching
33 lines • 1.57 kB
TypeScript
interface UseGlobalMutationParams<T> {
url: string;
queriesToInvalidate?: string[];
methodType: "POST" | "PUT" | "DELETE";
data?: T;
isFormData?: boolean;
closePopup?: (state: boolean) => void;
excludedIndexKeys?: string[];
}
interface MutationFunctionParams<T> {
isPriorityDataAvailable?: boolean;
priorityData?: T;
}
/**
* Custom hook for handling global mutations with React Query.
* @param {string} url - The endpoint URL for the mutation.
* @param {Array<string>} queriesToInvalidate - Array of query keys to invalidate after successful mutation.
* @param {string} methodType - The HTTP method type (POST, PUT, DELETE).
* @param {Object} [data] - The default data to be sent with the mutation.
* @param {boolean} [isFormData] - Whether the data should be processed as FormData.
* @param {Function} [closePopup] - Optional callback to close a popup after successful mutation.
* @param {Array<string>} [excludedIndexKeys] - Keys for which array indices should not be included in FormData.
* @returns {Object} An object containing mutation-related functions and state.
*/
export declare const useGlobalMutation: <T extends Record<string, any>>({ url, queriesToInvalidate, methodType, data, isFormData, closePopup, excludedIndexKeys, }: UseGlobalMutationParams<T>) => {
runMutation: (params?: MutationFunctionParams<T>) => void;
mutationLoading: boolean;
mutationData: any;
mutationError: string | undefined;
isMutationSucceeded: boolean;
};
export {};
//# sourceMappingURL=useGlobalMutation.d.ts.map