Skip to content

Commit f86970f

Browse files
committed
docs: update QueryClient example and update API reference
- Update example with staleTime and gcTime, and enableDevTools usage - Document queryClient, options, and enableDevTools props in Component Properties - Fix typo: items.description -> item.description in useItem example - Fix malformed Error type table markdown
1 parent 2752ceb commit f86970f

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,24 @@ If you want to provide your own custom QueryClient (for advanced caching or devt
5353
import { StacApiProvider } from 'stac-react';
5454
import { QueryClient } from '@tanstack/react-query';
5555

56-
const queryClient = new QueryClient();
56+
const queryClient = new QueryClient({
57+
defaultOptions: {
58+
queries: {
59+
staleTime: 5 * 60 * 1000, // 5 minutes
60+
gcTime: 10 * 60 * 1000, // 10 minutes
61+
},
62+
},
63+
});
5764

5865
function StacApp() {
66+
const isDevelopment = process.env.NODE_ENV === 'development';
67+
5968
return (
60-
<StacApiProvider apiUrl="https://my-stac-api.com" queryClient={queryClient}>
69+
<StacApiProvider
70+
apiUrl="https://my-stac-api.com"
71+
queryClient={queryClient}
72+
enableDevTools={isDevelopment}
73+
>
6174
{/* Other components */}
6275
</StacApiProvider>
6376
);
@@ -110,9 +123,12 @@ function StacApp() {
110123

111124
##### Component Properties
112125

113-
| Option | Type | Description |
114-
| --------- | -------- | --------------------------------- |
115-
| `apiUrl`. | `string` | The base url of the STAC catalog. |
126+
| Option | Type | Description |
127+
| ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
128+
| `apiUrl` | `string` | The base URL of the STAC catalog. |
129+
| `queryClient` | `QueryClient` | Optional. Custom TanStack Query QueryClient instance. If not provided, a default QueryClient will be created. |
130+
| `options` | `object` | Optional. Configuration object for customizing STAC API requests (e.g., headers, authentication). |
131+
| `enableDevTools` | `boolean` | Optional. Enables TanStack Query DevTools browser extension integration by exposing the QueryClient on `window.__TANSTACK_QUERY_CLIENT__`. Defaults to `false`. Recommended for development only. |
116132

117133
### useCollections
118134

@@ -259,7 +275,7 @@ function Item() {
259275
{item ? (
260276
<>
261277
<h2>{item.id}</h2>
262-
<p>{items.description}</p>
278+
<p>{item.description}</p>
263279
</>
264280
) : (
265281
<p>Not found</p>
@@ -494,11 +510,11 @@ function StacComponent() {
494510
}
495511
```
496512

497-
| Option | Type | Description |
498-
| ------------ | -------- | --------------------------------- | ------------------------------------------------------------------------------------------ |
499-
| `detail` | `string` | `object | The error return from the API. Either a`string` or and `object` depending on the response. |
500-
| `status` | `number` | HTTP status code of the response. |
501-
| `statusText` | `string` | Status text for the response. |
513+
| Option | Type | Description |
514+
| ------------ | ------------------ | -------------------------------------------------------------------------------------------- |
515+
| `detail` | `string \| object` | The error returned from the API. Either a `string` or an `object` depending on the response. |
516+
| `status` | `number` | HTTP status code of the response. |
517+
| `statusText` | `string` | Status text for the response. |
502518

503519
## Development
504520

0 commit comments

Comments
 (0)