Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Update <Search> and <SearchWithResult> to introduce queryOptions #9779

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions docs/Search.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ export const App = () => (

The `<Search>` component accepts the following props:

| Prop | Required | Type | Default | Description |
| ------------- | -------- | --------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
| `children` | Optional | `Element` | `<SearchResultsPanel>` | A component that will display the results. |
| `color` | Optional | `string` | `light` | The color mode for the input, applying light or dark backgrounds. Accept either `light` or `dark`. |
| `historySize` | Optional | `number` | 5 | The number of past queries to keep in history. |
| `options` | Optional | `Object` | - | An object containing options to apply to the search. |
| `wait` | Optional | `number` | 500 | The delay of debounce for the search to launch after typing in ms. |
| Prop | Required | Type | Default | Description |
| -------------- | -------- | --------------------------------------------------------------------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
| `children` | Optional | `Element` | `<SearchResultsPanel>` | A component that will display the results. |
| `color` | Optional | `string` | `light` | The color mode for the input, applying light or dark backgrounds. Accept either `light` or `dark`. |
| `historySize` | Optional | `number` | 5 | The number of past queries to keep in history. |
| `options` | Optional | `Object` | - | An object containing options to apply to the search. |
| `queryOptions` | Optional | [`UseQuery Options`](https://tanstack.com/query/v3/docs/react/reference/useQuery) | - | `react-query` options for the search query |
| `wait` | Optional | `number` | 500 | The delay of debounce for the search to launch after typing in ms. |

Additional props are passed down to the Material UI [`<TextField>`](https://mui.com/material-ui/react-text-field/) component.

Expand Down Expand Up @@ -238,6 +239,18 @@ An object containing options to apply to the search:
```
{% endraw %}

## `queryOptions`

`<Search>` accepts a [`queryOptions` prop](https://tanstack.com/query/v3/docs/framework/react/reference/useQuery) to pass options to the react-query client.
This can be useful e.g. to override the default side effects such as `onSuccess` or `onError`.


{% raw %}
```tsx
<Search queryOptions={{ onSuccess: data => console.log(data) }} />
```
{% endraw %}

## `wait`

The number of milliseconds to wait before processing the search request, immediately after the user enters their last character.
Expand Down
27 changes: 20 additions & 7 deletions docs/SearchWithResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ Check [the `ra-search` documentation](https://react-admin-ee.marmelab.com/docume

## Props

| Prop | Required | Type | Default | Description |
| ------------ | -------- | ---------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `children` | Optional | `Element` | `<SearchResultsPanel>` | A component that will display the results. |
| `color` | Optional | `string` | The opposite of theme mode. If mode is `light` default is `dark` and vice versa | The color mode for the input, applying light or dark backgrounds. Accept either `light` or `dark`. |
| `onNavigate` | Optional | `function` | `() => undefined` | A callback function to run when the user navigate to a result. |
| `options` | Optional | `Object` | - | An object containing options to apply to the search. |
| `wait` | Optional | `number` | 500 | The delay of debounce for the search to launch after typing in ms. |
| Prop | Required | Type | Default | Description |
| ------------ | -------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `children` | Optional | `Element` | `<SearchResultsPanel>` | A component that will display the results. |
| `color` | Optional | `string` | The opposite of theme mode. If mode is `light` default is `dark` and vice versa | The color mode for the input, applying light or dark backgrounds. Accept either `light` or `dark`. |
| `onNavigate` | Optional | `function` | `() => undefined` | A callback function to run when the user navigate to a result. |
| `options` | Optional | `Object` | - | An object containing options to apply to the search. |
| `queryOptions` | Optional | [`UseQuery Options`](https://tanstack.com/query/v3/docs/react/reference/useQuery) | - | `react-query` options for the search query |
| `wait` | Optional | `number` | 500 | The delay of debounce for the search to launch after typing in ms. |

## `children`

Expand Down Expand Up @@ -187,6 +188,18 @@ An object containing options to apply to the search:
```
{% endraw %}

## `queryOptions`

`<SearchWithResult>` accepts a [`queryOptions` prop](https://tanstack.com/query/v3/docs/framework/react/reference/useQuery) to pass options to the react-query client.
This can be useful e.g. to override the default side effects such as `onSuccess` or `onError`.


{% raw %}
```tsx
<SearchWithResult queryOptions={{ onSuccess: data => console.log(data) }} />
```
{% endraw %}

## `wait`

The number of milliseconds to wait before processing the search request, immediately after the user enters their last character.
Expand Down
Loading