File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ export const UserResource = createResource({
114
114
115
115
``` tsx title="UsersPage"
116
116
import { schema } from ' @data-client/rest' ;
117
- import { useQuery , useFetch } from ' @data-client/react' ;
117
+ import { useQuery , useSuspense } from ' @data-client/react' ;
118
118
import { UserResource , User } from ' ./api/User' ;
119
119
120
120
const getUserCount = new schema .Query (
@@ -127,11 +127,11 @@ const getUserCount = new schema.Query(
127
127
);
128
128
129
129
function UsersPage() {
130
- useFetch (UserResource .getList );
130
+ useSuspense (UserResource .getList );
131
131
const userCount = useQuery (getUserCount );
132
132
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 ;
135
135
return (
136
136
<div >
137
137
<div >Total users: { userCount } </div >
You can’t perform that action at this time.
0 commit comments