@trackunit/react-graphql-hooks 0.0.232 → 0.0.234

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.
package/index.cjs.js CHANGED
@@ -175,8 +175,11 @@ const usePaginationQuery = (document, { ...props }) => {
175
175
  onReset,
176
176
  });
177
177
  const doFetchMore = react.useCallback((variables, prev) => {
178
- setIsLoading(true);
178
+ if (internalProps.skip) {
179
+ return;
180
+ }
179
181
  const abortController = new AbortController();
182
+ setIsLoading(true);
180
183
  /**
181
184
  * To support pagination with page and pageSize, we need to convert the variables from first and after.
182
185
  */
@@ -236,7 +239,7 @@ const usePaginationQuery = (document, { ...props }) => {
236
239
  react.useEffect(() => {
237
240
  const abortController = doFetchMore({ first, last: undefined, before: undefined, after: undefined }, undefined);
238
241
  return () => {
239
- abortController.abort();
242
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort();
240
243
  };
241
244
  // eslint-disable-next-line react-hooks/exhaustive-deps
242
245
  }, [internalProps.variables, resetTrigger]);
package/index.esm.js CHANGED
@@ -154,8 +154,11 @@ const usePaginationQuery = (document, { ...props }) => {
154
154
  onReset,
155
155
  });
156
156
  const doFetchMore = useCallback((variables, prev) => {
157
- setIsLoading(true);
157
+ if (internalProps.skip) {
158
+ return;
159
+ }
158
160
  const abortController = new AbortController();
161
+ setIsLoading(true);
159
162
  /**
160
163
  * To support pagination with page and pageSize, we need to convert the variables from first and after.
161
164
  */
@@ -215,7 +218,7 @@ const usePaginationQuery = (document, { ...props }) => {
215
218
  useEffect(() => {
216
219
  const abortController = doFetchMore({ first, last: undefined, before: undefined, after: undefined }, undefined);
217
220
  return () => {
218
- abortController.abort();
221
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort();
219
222
  };
220
223
  // eslint-disable-next-line react-hooks/exhaustive-deps
221
224
  }, [internalProps.variables, resetTrigger]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-graphql-hooks",
3
- "version": "0.0.232",
3
+ "version": "0.0.234",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -27,6 +27,10 @@ export interface PaginationQueryProps<TData, TVariables extends ApolloClient.Ope
27
27
  * If not specified, the default page size is 50.
28
28
  */
29
29
  pageSize?: number;
30
+ /**
31
+ * A boolean value that specifies whether to skip the query.
32
+ */
33
+ skip?: boolean;
30
34
  }
31
35
  /**
32
36
  * This hook is used to fetch data from a GraphQL query and support pagination, it will help maintain the data and the pagination.