@ventlio/tanstack-query 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,13 +63,13 @@ export const usePatchRequest = <TResponse>({ path, baseUrl, headers }: { path: s
63
63
  };
64
64
 
65
65
  // register post mutation
66
- const mutation = useMutation<IRequestSuccess<TResponse>, IRequestError>({
67
- mutationFn: (dataData: any) =>
66
+ const mutation = useMutation<IRequestSuccess<TResponse>, IRequestError>(
67
+ (dataData: any) =>
68
68
  new Promise<IRequestSuccess<TResponse>>((res, rej) => {
69
69
  return sendRequest(res, rej, dataData);
70
70
  }),
71
- mutationKey: [path, { type: 'mutation' }],
72
- });
71
+ { mutationKey: [path, { type: 'mutation' }] }
72
+ );
73
73
 
74
74
  const patch = async (
75
75
  data: any,
@@ -91,5 +91,5 @@ export const usePatchRequest = <TResponse>({ path, baseUrl, headers }: { path: s
91
91
  // eslint-disable-next-line react-hooks/exhaustive-deps
92
92
  }, [isFutureMutationsPaused]);
93
93
 
94
- return { patch, uploadProgressPercent, ...mutation, isLoading: mutation.isPending || isFutureMutationsPaused };
94
+ return { patch, uploadProgressPercent, ...mutation, isLoading: mutation.isLoading || isFutureMutationsPaused };
95
95
  };
@@ -95,9 +95,7 @@ export const usePostRequest = <TResponse>({
95
95
  IRequestSuccess<TResponse>,
96
96
  IRequestError,
97
97
  { data: any; requestConfig?: Partial<Omit<IMakeRequest, 'body'>> }
98
- >({
99
- mutationFn: async (postData) =>
100
- new Promise<IRequestSuccess<TResponse>>((res, rej) => sendRequest(res, rej, postData)),
98
+ >(async (postData) => new Promise<IRequestSuccess<TResponse>>((res, rej) => sendRequest(res, rej, postData)), {
101
99
  mutationKey: [path, { type: 'mutation' }],
102
100
  });
103
101
 
@@ -131,5 +129,5 @@ export const usePostRequest = <TResponse>({
131
129
  // eslint-disable-next-line react-hooks/exhaustive-deps
132
130
  }, [isFutureMutationsPaused]);
133
131
 
134
- return { post, uploadProgressPercent, ...mutation, isLoading: mutation.isPending || isFutureMutationsPaused };
132
+ return { post, uploadProgressPercent, ...mutation, isLoading: mutation.isLoading || isFutureMutationsPaused };
135
133
  };