Skip to main content

useWatchedQuerySuspenseSubscription()

function useWatchedQuerySuspenseSubscription<ResultType, Query>(query): Query["state"]

A hook to access and subscribe to the results of an existing WatchedQuery.

Type Parameters

Type ParameterDefault type
ResultTypeunknown
Query extends WatchedQuery<ResultType, WatchedQueryOptions, WatchedQueryListener<ResultType>>WatchedQuery<ResultType, WatchedQueryOptions, WatchedQueryListener<ResultType>>

Parameters

ParameterType
queryQuery

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>
);
}