Skip to main content

useSuspenseQuery()

function useSuspenseQuery<T>(
query,
parameters,
options): SuspenseQueryResult<T>

A hook to access the results of a watched query that suspends until the initial result has loaded.

Type parameters

Type parameterValue
Tany

Parameters

ParameterTypeDefault value
querystring | CompilableQuery<T>undefined
parametersany[][]
optionsAdditionalOptions{}

Returns

SuspenseQueryResult<T>

Example

export const ContentComponent = () => {
const { data: lists } = useSuspenseQuery('SELECT * from lists');

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