useWatchedQuerySuspenseSubscription()
function useWatchedQuerySuspenseSubscription<ResultType, Query>(query): Query["state"]
A hook to access and subscribe to the results of an existing WatchedQuery.
Type Parameters
| Type Parameter | Default type |
|---|---|
ResultType | unknown |
Query extends WatchedQuery<ResultType, WatchedQueryOptions, WatchedQueryListener<ResultType>> | WatchedQuery<ResultType, WatchedQueryOptions, WatchedQueryListener<ResultType>> |
Parameters
| Parameter | Type |
|---|---|
query | Query |
Returns
Query["state"]
Example
export const ContentComponent = () => {
const { data: lists } = useWatchedQuerySuspenseSubscription(listsQuery);
return <View>
{lists.map((l) => (
<Text key={l.id}>{JSON.stringify(l)}</Text>
))}
</View>;
}
export const DisplayComponent = () => {
return (
<Suspense fallback={<div>Loading content...</div>}>
<ContentComponent />
</Suspense>
);
}