You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* let’s do it again
* fix test group
* maybe
* mkay
* cool
* rm console.logs
* mkay
* mkay
* fix(vue-query): invalidate queries immediately after calling `invalidateQueries` (#7930)
* fix(vue-query): invalidate queries immediately after call `invalidateQueries`
* chore: recovery code comments
* release: v5.53.2
* docs(vue-query): update SSR guide for nuxt2 (#8001)
* docs: update SSR guide for nuxt2
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* thenable
* mkay
* Update packages/react-query/src/__tests__/useQuery.test.tsx
* mkay
* mkay
* faster and more consistent
* mkay
* mkay
* mkay
* mkay
* mkay
* fix unhandled rejections
* more
* more
* mkay
* fix more
* fixy
* cool
* Update packages/react-query/package.json
* fix: track data property if `promise` is tracked
if users use the `promise` returned from useQuery, they are actually interested in the `data` it unwraps to. Since the promise doesn't change when data resolves, we would likely miss a re-render
* Revert "fix: track data property if `promise` is tracked"
This reverts commit d1184ba.
* add test case that @TkDodo was concerned about
* tweak
* mkay
* add `useInfiniteQuery()` test
* consistent testing
* better test
* rm comment
* test resetting errror boundary
* better test
* cool
* cool
* more test
* mv cleanup
* mkay
* some more things
* add fixme
* fix types
* wat
* fixes
* revert
* fix
* colocating doesn’t workkk
* mkay
* mkay
* might work
* more test
* cool
* i don’t know hwat i’m doing
* mocky
* lint
* space
* rm log
* setIsServer
* mkay
* ffs
* remove unnecessary stufffff
* tweak more
* just naming and comments
* tweak
* fix: use fetchOptimistic util instead of observer.fetchOptimistic
* refactor: make sure to only trigger fetching during render if we really have no cache entry yet
* fix: move the `isNewCacheEntry` check before observer creation
* chore: avoid rect key warnings
* fix: add an `updateResult` for all observers to finalize currentThenable
* chore: logs during suspense errors
* fix: empty catch
* feature flag
* add comment
* simplify
* omit from suspense
* feat flag
* more tests
* test: scope experimental_promise to useQuery().promise tests
* refactor: rename to experimental_prefetchInRender
* test: more tests
* test: more cancelation
* fix cancellation
* make it work
* tweak comment
* Update packages/react-query/src/useBaseQuery.ts
* simplify code a bit
* Update packages/query-core/src/queryObserver.ts
* refactor: move experimental_prefetchInRender check until after the early bail-out
* fix: when cancelled, the promise should stay pending
* test: disabled case
* chore: no idea what's going on
* refactor: delete unnecessary check
* revert refactor i did for cancellation when we wanted it to `throw`
* add docs
* align
* tweak
* Update docs/reference/QueryClient.md
* Update docs/framework/react/reference/queryOptions.md
---------
Co-authored-by: Alex Liu <[email protected]>
Co-authored-by: Tanner Linsley <[email protected]>
Co-authored-by: Damian Osipiuk <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <[email protected]>
- Additionally, you can use the `useQuery().promise` and `React.use()` (Experimental)
11
12
12
13
When using suspense mode, `status` states and `error` objects are not needed and are then replaced by usage of the `React.Suspense` component (including the use of the `fallback` prop and React error boundaries for catching errors). Please read the [Resetting Error Boundaries](#resetting-error-boundaries) and look at the [Suspense Example](https://stackblitz.com/github/TanStack/query/tree/main/examples/react/suspense) for more information on how to set up suspense mode.
For more information, check out the [NextJs Suspense Streaming Example](../../examples/nextjs-suspense-streaming) and the [Advanced Rendering & Hydration](../advanced-ssr) guide.
176
+
177
+
## Using `useQuery().promise` and `React.use()` (Experimental)
178
+
179
+
> To enable this feature, you need to set the `experimental_prefetchInRender` option to `true` when creating your `QueryClient`
180
+
181
+
**Example code:**
182
+
183
+
```tsx
184
+
const queryClient =newQueryClient({
185
+
defaultOptions: {
186
+
queries: {
187
+
experimental_prefetchInRender: true,
188
+
},
189
+
},
190
+
})
191
+
```
192
+
193
+
**Usage:**
194
+
195
+
```tsx
196
+
importReactfrom'react'
197
+
import { useQuery } from'@tanstack/react-query'
198
+
import { fetchTodos, typeTodo } from'./api'
199
+
200
+
function TodoList({ query }: { query:UseQueryResult<Todo[]> }) {
Copy file name to clipboardExpand all lines: docs/framework/react/reference/useInfiniteQuery.md
+5
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ const {
11
11
hasPreviousPage,
12
12
isFetchingNextPage,
13
13
isFetchingPreviousPage,
14
+
promise,
14
15
...result
15
16
} =useInfiniteQuery({
16
17
queryKey,
@@ -85,5 +86,9 @@ The returned properties for `useInfiniteQuery` are identical to the [`useQuery`
85
86
- Is the same as `isFetching && !isPending && !isFetchingNextPage && !isFetchingPreviousPage`
86
87
-`isRefetchError: boolean`
87
88
- Will be `true` if the query failed while refetching a page.
89
+
-`promise: Promise<TData>`
90
+
- A stable promise that resolves to the query result.
91
+
- This can be used with `React.use()` to fetch data
92
+
- Requires the `experimental_prefetchInRender` feature flag to be enabled on the `QueryClient`.
88
93
89
94
Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default refetch behaviour, resulting in outdated data. Make sure to call these functions only in response to user actions, or add conditions like `hasNextPage && !isFetching`.
0 commit comments