@raf-query/react 0.10.1 → 0.10.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.
- package/CHANGELOG.md +9 -2
- package/dist/use-query.d.mts +11 -3
- package/dist/use-query.mjs +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.10.2](https://github.com/KATT/raf-query/compare/0.10.1...0.10.2) (2026-10-16)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **react:** re-render useQuery readers of the thenable's status when the first load settles (2/3) ([#198](https://github.com/KATT/raf-query/issues/198)) ([436d83c](https://github.com/KATT/raf-query/commit/436d83cfd6a3944265eb56d5597c322342c5a6c6))
|
|
8
|
+
* **react:** type useQuery's promise as a Thenable (1/3) ([#200](https://github.com/KATT/raf-query/issues/200)) ([47e5309](https://github.com/KATT/raf-query/commit/47e530957565a2bd345642ae7a4be5d3c501ffb2))
|
|
9
|
+
|
|
3
10
|
## [0.10.1](https://github.com/KATT/raf-query/compare/0.10.0...0.10.1) (2026-10-16)
|
|
4
11
|
|
|
5
12
|
### Features
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
- **core:** export QueryClient, dehydrate, hydrate, allKeyed and the useQuery controls from @raf-query/core ([#193](https://github.com/KATT/raf-query/issues/193)) ([54492ab](https://github.com/KATT/raf-query/commit/54492abbe2966a0645e8a4c77f9c5ab31d6e3a20)), references [#194](https://github.com/KATT/raf-query/issues/194)
|
|
8
15
|
|
|
9
16
|
### Documentation
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
- React Router client-only and server sections with one server client per request, Effect under Integrations, official docs links, and ensure waits like fetch in server-only code ([#192](https://github.com/KATT/raf-query/issues/192)) ([841ffcf](https://github.com/KATT/raf-query/commit/841ffcf4d0fa0a40dfc58dc65bfcfadca8948874)), references [#190](https://github.com/KATT/raf-query/issues/190)
|
|
12
19
|
|
|
13
20
|
## [0.10.0](https://github.com/KATT/raf-query/compare/0.9.2...0.10.0) (2026-10-16)
|
|
14
21
|
|
package/dist/use-query.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataOf, ErrorOf, QueryFactory, QueryHandle, QueryHandleWithData, ThrowsOnError, UseQueryControls, UseQueryOptions, UseQueryThrowOptions } from "@raf-query/core";
|
|
1
|
+
import { DataOf, ErrorOf, QueryFactory, QueryHandle, QueryHandleWithData, Thenable, ThrowsOnError, UseQueryControls, UseQueryOptions, UseQueryThrowOptions } from "@raf-query/core";
|
|
2
2
|
import { Result } from "effect";
|
|
3
3
|
//#region src/use-query.d.ts
|
|
4
|
-
export type UseQueryResult<TFactory extends QueryFactory, TThrow extends boolean | undefined = undefined> = ThrowsOnError<TFactory, TThrow> extends true ? readonly [promise:
|
|
4
|
+
export type UseQueryResult<TFactory extends QueryFactory, TThrow extends boolean | undefined = undefined> = ThrowsOnError<TFactory, TThrow> extends true ? readonly [promise: Thenable<DataOf<TFactory>>, controls: UseQueryControls<TFactory>] : readonly [promise: Thenable<Result.Result<DataOf<TFactory>, ErrorOf<TFactory>>>, controls: UseQueryControls<TFactory>];
|
|
5
5
|
/** {@link useQuery}'s result for a handle from `ensure` or `fetch`. */
|
|
6
6
|
export type UseQueryResultWithData<TFactory extends QueryFactory, TThrow extends boolean | undefined = undefined> = ThrowsOnError<TFactory, TThrow> extends true ? readonly [data: DataOf<TFactory>, controls: UseQueryControls<TFactory>] : readonly [result: Result.Result<DataOf<TFactory>, ErrorOf<TFactory>>, controls: UseQueryControls<TFactory>];
|
|
7
7
|
/**
|
|
@@ -26,7 +26,15 @@ export type UseQueryResultWithData<TFactory extends QueryFactory, TThrow extends
|
|
|
26
26
|
* The promise is stable per data version and already fulfilled once the
|
|
27
27
|
* cache has data, so `use()` only suspends while there is nothing to show.
|
|
28
28
|
* The component re-renders when the promise changes, and when a control it
|
|
29
|
-
* has read changes; changes to controls it never reads are skipped.
|
|
29
|
+
* has read changes; changes to controls it never reads are skipped. A
|
|
30
|
+
* first load settles its pending promise in place: that counts as a change
|
|
31
|
+
* once the component has read the promise's `status`, `value` or `reason`,
|
|
32
|
+
* so reading them without `use()` re-renders when the data lands:
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const [tagPromise] = useQuery(tagQuery, loaderData.tag);
|
|
36
|
+
* const tag = tagPromise.status === "fulfilled" ? tagPromise.value : "…";
|
|
37
|
+
* ```
|
|
30
38
|
*
|
|
31
39
|
* A handle from `ensure` or `fetch` already has its data, so the hook
|
|
32
40
|
* unwraps the promise itself and returns the data (or `Result`):
|
package/dist/use-query.mjs
CHANGED
|
@@ -51,10 +51,10 @@ function useQuery(factory, handle, options = {}) {
|
|
|
51
51
|
if (!throwOnError) {
|
|
52
52
|
const resultPromise = resultThenable(result.promise);
|
|
53
53
|
if (withData) return [use(resultPromise), controls];
|
|
54
|
-
return [resultPromise, controls];
|
|
54
|
+
return [QueryObserver.trackThenable(observer, resultPromise), controls];
|
|
55
55
|
}
|
|
56
56
|
if (withData) return [use(result.promise), controls];
|
|
57
|
-
return [result.promise, controls];
|
|
57
|
+
return [QueryObserver.trackThenable(observer, result.promise), controls];
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
60
|
export { useQuery };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raf-query/react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "React bindings for raf-query, a render-as-you-fetch query library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@raf-query/core": "0.10.
|
|
51
|
+
"@raf-query/core": "0.10.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tanstack/react-router": "^1.170.0",
|