@toapi/react 1.2.4 → 1.2.5
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/dist/use-query.d.ts.map +1 -1
- package/dist/use-query.js +8 -7
- package/package.json +8 -8
package/dist/use-query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../src/use-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAEvD,UAAU,OAAO;IACf,eAAe,CAAC,EAAE,OAAO,KAAK,CAAC,eAAe,CAAC;CAChD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1D,EAAE,eAAuC,EAAE,GAAE,OAAY,
|
|
1
|
+
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../src/use-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAEvD,UAAU,OAAO;IACf,eAAe,CAAC,EAAE,OAAO,KAAK,CAAC,eAAe,CAAC;CAChD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1D,EAAE,eAAuC,EAAE,GAAE,OAAY,KAmC1D"}
|
package/dist/use-query.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export function useQuery(query, { startTransition = React.startTransition } = {}) {
|
|
3
3
|
const observable = React.useMemo(typeof query === "function" ? query : () => query, [query]);
|
|
4
|
-
// The
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// The client keeps queryKey stable for the lifetime of a cached query,
|
|
5
|
+
// while each refresh returns a new promise. Comparing promises would mistake
|
|
6
|
+
// an inline factory's next render for a query switch and suspend on refresh.
|
|
7
|
+
// Custom observables without a key retain their existing identity semantics.
|
|
8
|
+
const source = observable.queryKey ?? observable;
|
|
8
9
|
const [state, setState] = React.useState(null);
|
|
9
10
|
React.useEffect(() => {
|
|
10
11
|
let active = true;
|
|
@@ -14,15 +15,15 @@ export function useQuery(query, { startTransition = React.startTransition } = {}
|
|
|
14
15
|
// A late update from a subscription we have already left behind must
|
|
15
16
|
// not overwrite the current one.
|
|
16
17
|
if (active)
|
|
17
|
-
setState({ source
|
|
18
|
+
setState({ source, value });
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
return () => {
|
|
21
22
|
active = false;
|
|
22
23
|
unsubscribe();
|
|
23
24
|
};
|
|
24
|
-
}, [
|
|
25
|
-
return state !== null && state.source ===
|
|
25
|
+
}, [source, startTransition]);
|
|
26
|
+
return state !== null && state.source === source
|
|
26
27
|
? state.value
|
|
27
28
|
: React.use(observable);
|
|
28
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toapi/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Michel Smola",
|
|
6
6
|
"email": "michel.smola@farbenmeer.de"
|
|
@@ -18,24 +18,24 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@toapi/common": "^1.2.
|
|
21
|
+
"@toapi/common": "^1.2.5"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@toapi/client": "^1.2.5",
|
|
25
|
+
"@toapi/server": "^1.2.5",
|
|
24
26
|
"@happy-dom/global-registrator": "^20.0.0",
|
|
25
27
|
"@testing-library/dom": "^10.4.1",
|
|
26
|
-
"@testing-library/jest-dom": "^
|
|
28
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
27
29
|
"@testing-library/react": "^16.3.0",
|
|
28
30
|
"@types/node": "^25.0.3",
|
|
29
31
|
"@types/react": "^19.2.7",
|
|
30
32
|
"react": "^19.1.1",
|
|
31
|
-
"vitest": "^
|
|
32
|
-
"zod": "^4.1.5"
|
|
33
|
-
"@toapi/server": "^1.2.4",
|
|
34
|
-
"@toapi/client": "^1.2.4"
|
|
33
|
+
"vitest": "^5.0.0",
|
|
34
|
+
"zod": "^4.1.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^19.1.1",
|
|
38
|
-
"typescript": "^5 || ^6.0.0"
|
|
38
|
+
"typescript": "^5 || ^6.0.0 || ^7.0.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -p tsconfig.build.json",
|