@trackunit/react-graphql-hooks 1.3.164 → 1.3.165

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
@@ -136,7 +136,8 @@ const unionEdgesByNodeKey = (key, previousEdges, newEdges) => {
136
136
  const usePaginationQuery = (document, { ...props }) => {
137
137
  const [lastFetchedData, setLastFetchedData] = react.useState();
138
138
  const [resetTrigger, setResetTrigger] = react.useState(0);
139
- const [abortController] = react.useState(new AbortController());
139
+ const [abortController, setAbortController] = react.useState(new AbortController());
140
+ const [lastAbortController, setLastAbortController] = react.useState(undefined);
140
141
  // Makes **sure** query variables are stable.
141
142
  // Before, it required variables to always be memorized in the parent which was easy to forget and confusing.
142
143
  // Maybe better solution exists but this is the best I could come up with without changing to much.
@@ -149,7 +150,16 @@ const usePaginationQuery = (document, { ...props }) => {
149
150
  if (!isEqual(props.variables, variablesRef.current)) {
150
151
  variablesRef.current = props.variables;
151
152
  setStableVariables(props.variables);
153
+ if (!props.skip) {
154
+ if (lastAbortController) {
155
+ lastAbortController.abort();
156
+ }
157
+ const newAbortController = new AbortController();
158
+ setLastAbortController(newAbortController);
159
+ setAbortController(newAbortController);
160
+ }
152
161
  }
162
+ // eslint-disable-next-line
153
163
  }, [props.variables]);
154
164
  const internalProps = react.useMemo(() => {
155
165
  return {
package/index.esm.js CHANGED
@@ -115,7 +115,8 @@ const unionEdgesByNodeKey = (key, previousEdges, newEdges) => {
115
115
  const usePaginationQuery = (document, { ...props }) => {
116
116
  const [lastFetchedData, setLastFetchedData] = useState();
117
117
  const [resetTrigger, setResetTrigger] = useState(0);
118
- const [abortController] = useState(new AbortController());
118
+ const [abortController, setAbortController] = useState(new AbortController());
119
+ const [lastAbortController, setLastAbortController] = useState(undefined);
119
120
  // Makes **sure** query variables are stable.
120
121
  // Before, it required variables to always be memorized in the parent which was easy to forget and confusing.
121
122
  // Maybe better solution exists but this is the best I could come up with without changing to much.
@@ -128,7 +129,16 @@ const usePaginationQuery = (document, { ...props }) => {
128
129
  if (!isEqual(props.variables, variablesRef.current)) {
129
130
  variablesRef.current = props.variables;
130
131
  setStableVariables(props.variables);
132
+ if (!props.skip) {
133
+ if (lastAbortController) {
134
+ lastAbortController.abort();
135
+ }
136
+ const newAbortController = new AbortController();
137
+ setLastAbortController(newAbortController);
138
+ setAbortController(newAbortController);
139
+ }
131
140
  }
141
+ // eslint-disable-next-line
132
142
  }, [props.variables]);
133
143
  const internalProps = useMemo(() => {
134
144
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-graphql-hooks",
3
- "version": "1.3.164",
3
+ "version": "1.3.165",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,7 +10,7 @@
10
10
  "@apollo/client": "3.13.8",
11
11
  "react": "19.0.0",
12
12
  "lodash": "4.17.21",
13
- "@trackunit/i18n-library-translation": "1.3.160",
13
+ "@trackunit/i18n-library-translation": "1.3.161",
14
14
  "@trackunit/shared-utils": "1.5.141",
15
15
  "@trackunit/react-table-pagination": "1.3.141",
16
16
  "@trackunit/react-test-setup": "1.0.31"