Skip to content

Commit d9eda63

Browse files
committed
docs: Change hook in computed properties example
1 parent f8719f4 commit d9eda63

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/rest/guides/computed-properties.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const UserResource = createResource({
114114

115115
```tsx title="UsersPage"
116116
import { schema } from '@data-client/rest';
117-
import { useQuery, useFetch } from '@data-client/react';
117+
import { useQuery, useSuspense } from '@data-client/react';
118118
import { UserResource, User } from './api/User';
119119

120120
const getUserCount = new schema.Query(
@@ -127,11 +127,11 @@ const getUserCount = new schema.Query(
127127
);
128128

129129
function UsersPage() {
130-
useFetch(UserResource.getList);
130+
useSuspense(UserResource.getList);
131131
const userCount = useQuery(getUserCount);
132132
const adminCount = useQuery(getUserCount, { isAdmin: true });
133-
if (userCount === undefined)
134-
return <div>No users in cache yet</div>;
133+
// this should never happen since we suspense but typescript does not know that
134+
if (userCount === undefined) return;
135135
return (
136136
<div>
137137
<div>Total users: {userCount}</div>

0 commit comments

Comments
 (0)