useQuery allows you call a defined query (via createQuery)
to obtain the signal-based value for display within your React component.
The return of useQuery is a read-only value which is the result of calling an Accessor.
Query's have built in support for Suspense and Error Boundaries with no extra effort.
To obtain a query value, simply pass in the defined query to the hook and bind the value in your JSX.
To utilize the native React Suspense API with your query, simply wrap the parent
of the component calling the query in Suspense as per requirements of the React
API.
To learn more about Suspense, read the React docs.
If a query errors out, createQuery will throw an error that will natively trigger
an Error Boundary if you have one established.
To learn more about Error Boundaries, see the Error Boundary library on NPM.
useQuery accepts the following options:
| Params | Required | Description |
|---|---|---|
Accessor<QueryState<T>> | true | The query to utilize. |
useQuery returns the value of the Promise defined in createQuery.
{
"id": "411809ca-e360-4f6f-aa8f-2b0e574dac8b",
"name": "User 411809ca-e360-4f6f-aa8f-2b0e574dac8b"
}