Skip to content

Commit 18c9f77

Browse files
authored
docs(@suspensive/react-query): update latest content (#5539)
1 parent 14c7b1e commit 18c9f77

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

docs/react/community/suspensive-react-query.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ id: suspensive-react-query
33
title: Suspensive React Query
44
---
55

6-
Typesafe useQuery, useInfiniteQuery with default suspense option.
6+
Typesafe useQuery, useQueries, useInfiniteQuery with default suspense option.
77

8-
Use @suspensive/react-query, delegate loading and error handling to the outside of the component with useSuspenseQuery and useSuspenseInfiniteQuery, and focus on success inside the component.
8+
Use @suspensive/react-query, delegate loading and error handling to the outside of the component with [useSuspenseQuery](https://suspensive.org/docs/react-query/src/useSuspenseQuery.i18n), [useSuspenseQueries](https://suspensive.org/docs/react-query/src/useSuspenseQueries.i18n) and [useSuspenseInfiniteQuery](https://suspensive.org/docs/react-query/src/useSuspenseInfiniteQuery.i18n), and focus on success inside the component.
99

1010
You don't even need to use the isSuccess flag.
1111

1212
## Installation
13+
1314
You can install @suspensive/react-query via [NPM](https://www.npmjs.com/package/@suspensive/react-query).
1415

1516
```bash
16-
$ npm i @suspensive/react @suspensive/react-query
17+
$ npm i @suspensive/react-query
1718
# or
18-
$ pnpm add @suspensive/react @suspensive/react-query
19+
$ pnpm add @suspensive/react-query
1920
# or
20-
$ yarn add @suspensive/react @suspensive/react-query
21+
$ yarn add @suspensive/react-query
2122
```
2223

2324
### Motivation
@@ -28,7 +29,9 @@ If you turn suspense mode on in @tanstack/react-query, You can use useQuery with
2829
import { useQuery } from '@tanstack/react-query'
2930

3031
const Example = () => {
31-
const query = useQuery(queryKey, queryFn, {
32+
const query = useQuery({
33+
queryKey,
34+
queryFn,
3235
suspense: true,
3336
})
3437

@@ -55,7 +58,10 @@ In addition, this hook's options have default suspense: true. and you can provid
5558
import { useSuspenseQuery } from '@suspensive/react-query'
5659

5760
const Example = () => {
58-
const query = useSuspenseQuery(queryKey, queryFn, options) // suspense:true is default.
61+
const query = useSuspenseQuery({
62+
queryKey,
63+
queryFn,
64+
}) // suspense:true is default.
5965

6066
// No need to do type narrowing by isSuccess
6167
query.data // TData
@@ -66,4 +72,6 @@ const Example = () => {
6672

6773
Now, we can concentrate component as any fetching will be always success in component.
6874

69-
Check the complete documentation on [GitHub](https://github.com/suspensive/react).
75+
### More Information
76+
77+
Check the complete documentation on [Suspensive Official Docs Site](https://suspensive.org/) and also welcome Pull Request on [Suspensive GitHub](https://github.com/suspensive/react)

docs/react/guides/suspense.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ const App: React.FC = () => {
101101
## Fetch-on-render vs Render-as-you-fetch
102102

103103
Out of the box, React Query in `suspense` mode works really well as a **Fetch-on-render** solution with no additional configuration. This means that when your components attempt to mount, they will trigger query fetching and suspend, but only once you have imported them and mounted them. If you want to take it to the next level and implement a **Render-as-you-fetch** model, we recommend implementing [Prefetching](../guides/prefetching) on routing callbacks and/or user interactions events to start loading queries before they are mounted and hopefully even before you start importing or mounting their parent components.
104+
105+
## Further reading
106+
107+
For tips on using suspense option, check the [Suspensive React Query Package](../community/suspensive-react-query) from the Community Resources.

0 commit comments

Comments
 (0)