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 parameter | Value |
---|---|
T | any |
Parameters
Parameter | Type | Default value |
---|---|---|
query | string | CompilableQuery <T > | undefined |
parameters | any [] | [] |
options | AdditionalOptions | {} |
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>
);
}