Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions docs/core/api/useSuspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ render(<ProfileDetail />);

Cache policy is [Stale-While-Revalidate](https://tools.ietf.org/html/rfc5861) by default but also [configurable](../concepts/expiry-policy.md).

| Expiry Status | Fetch | Suspend | Error | Conditions |
| ------------- | --------------- | ------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Expiry Status | Fetch | Suspend | Error | Conditions |
| ------------- | --------------- | ------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Invalid | yes<sup>1</sup> | yes | no | not in store, [deletion](/rest/api/resource#delete), [invalidation](./Controller.md#invalidate), [invalidIfStale](../concepts/expiry-policy.md#endpointinvalidifstale) |
| Stale | yes<sup>1</sup> | no | no | (first-render, arg change) & [expiry &lt; now](../concepts/expiry-policy.md) |
| Valid | no | no | maybe<sup>2</sup> | fetch completion |
| | no | no | no | `null` used as second argument |
| Stale | yes<sup>1</sup> | no | no | (first-render, arg change) & [expiry &lt; now](../concepts/expiry-policy.md) |
| Valid | no | no | maybe<sup>2</sup> | fetch completion |
| | no | no | no | `null` used as second argument |

:::note

Expand Down Expand Up @@ -348,11 +348,7 @@ export const getPosts = new RestEndpoint({
import { getPosts } from './api/Post';

export default function ArticleList({ page }: { page: string }) {
const {
posts,
nextPage,
lastPage,
} = useSuspense(getPosts, { page });
const { posts, nextPage, lastPage } = useSuspense(getPosts, { page });
return (
<div>
{posts.map(post => (
Expand Down Expand Up @@ -388,4 +384,4 @@ less intrusive _loading bar_, like [YouTube](https://youtube.com) and [Robinhood

<StackBlitz app="todo-app" file="src/pages/Home/TodoList.tsx,src/pages/Home/index.tsx,src/useNavigationState.ts" height={600} />

If you need help adding this to your own custom router, check out the [official React guide](https://react.dev/reference/react/useTransition#building-a-suspense-enabled-router)
If you need help adding this to your own custom router, check out the [official React guide](https://react.dev/reference/react/useTransition#building-a-suspense-enabled-router)
Loading