You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Admin.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -906,7 +906,7 @@ React-admin uses [React Query](https://tanstack.com/query/v5/) to fetch, cache a
906
906
* The query is optionally configured with a refetch interval
907
907
* Query results that are no longer used in the current page are labeled as "inactive" and remain in the cache in case they are used again at a later time.
908
908
* By default, "inactive" queries are garbage collected after 5 minutes.
909
-
* Queries that fail are silently retried 3 times, with exponential backoff delay before capturing and displaying an error to the UI.
909
+
* Queries that fail are silently retried 3 times, with exponential backoff delay before capturing and displaying an error notification to the UI.
910
910
* Query results by default are structurally shared to detect if data have actually changed and if not, the data reference remains unchanged to better help with value stabilization in regard to `useMemo` and `useCallback`.
911
911
912
912
If you want to override the react-query default query and mutation default options, or use a specific client or mutation cache, you can create your own `QueryClient` instance and pass it to the `<Admin queryClient>` prop:
Copy file name to clipboardExpand all lines: docs/DataProviderWriting.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -440,6 +440,8 @@ export default {
440
440
};
441
441
```
442
442
443
+
**Note**: Throwing an `httpError` in your `dataProvider` will result in a notify popup appearing in your admin UI.
444
+
443
445
## Handling Authentication
444
446
445
447
Your API probably requires some form of authentication (e.g. a token in the `Authorization` header). It's the responsibility of [the `authProvider`](./Authentication.md) to log the user in and obtain the authentication data. React-admin doesn't provide any particular way of communicating this authentication data to the Data Provider. Most of the time, storing the authentication data in the `localStorage` is the best choice - and allows uses to open multiple tabs without having to log in again.
* The query is optionally configured with a refetch interval
69
69
* Query results that are no longer used in the current page are labeled as "inactive" and remain in the cache in case they are used again later.
70
70
* By default, "inactive" queries are garbage collected after 5 minutes.
71
-
* Queries that fail are silently retried 3 times, with exponential backoff delay before capturing and displaying an error to the UI.
71
+
* Queries that fail are silently retried 3 times, with exponential backoff delay before capturing and displaying an error notification to the UI.
72
72
* Query results by default are structurally shared to detect if data has actually changed, and if not, the data reference remains unchanged to better help with value stabilization in regard to `useMemo` and `useCallback`.
73
73
74
74
If you want to override the react-query default query and mutation options, or use a specific client or mutation cache, you can create your own `QueryClient` instance and pass it to the `<Admin queryClient>` prop:
Copy file name to clipboardExpand all lines: docs/FAQ.md
+69-2Lines changed: 69 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,12 @@ title: "FAQ"
6
6
# FAQ
7
7
8
8
-[Can I have custom identifiers/primary keys for my resources?](#can-i-have-custom-identifiersprimary-keys-for-my-resources)
9
-
-[I get warning about unique key for child in array](#i-get-warning-about-unique-key-for-child-in-array)
9
+
-[I get a warning about unique key for child in array](#i-get-a-warning-about-unique-key-for-child-in-array)
10
10
-[How can I customize forms depending on its inputs values?](#how-can-i-customize-forms-depending-on-its-inputs-values)
11
11
-[UI in production build is empty or broken](#ui-in-production-build-is-empty-or-broken)
12
12
-[My Resource is defined but not displayed on the Menu](#my-resource-is-defined-but-not-displayed-on-the-menu)
13
+
-[I get an error about control being null](#i-get-an-error-about-control-being-null)
14
+
-[I get an error about a hook that may be used only in the context of a Router component](#i-get-an-error-about-a-hook-that-may-be-used-only-in-the-context-of-a-router-component)
13
15
14
16
## Can I have custom identifiers/primary keys for my resources?
15
17
@@ -118,7 +120,7 @@ const dataProvider = {
118
120
};
119
121
```
120
122
121
-
## I get warning about unique key for child in array
123
+
## I get a warning about unique key for child in array
122
124
123
125
When displaying a `Datagrid` component, you get the following warning:
In a view that contains a form, you may get the following error:
176
+
177
+
> Cannot read properties of null (reading 'control')
178
+
179
+
This is most probably because you have multiple versions of the `react-hook-form` package installed, one being a direct dependency in your project and the other brought by react-admin.
180
+
181
+
First, you can run `npm list react-hook-form` to check if you have duplicate versions.
182
+
183
+
To dedupe the package you can run `npm dedupe react-hook-form` or `yarn dedupe react-hook-form`.
184
+
185
+
You may also edit the lockfile manually.
186
+
187
+
Finally, you can use yarn’s [resolutions](https://yarnpkg.com/configuration/manifest#resolutions) or npm’s [overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) in your `package.json` file:
188
+
189
+
```json
190
+
{
191
+
"resolutions": {
192
+
"react-hook-form": "7.54.2"
193
+
}
194
+
}
195
+
```
196
+
197
+
## I get an error about a hook that may be used only in the context of a Router component
198
+
199
+
When using custom routing configurations, you may encounter strange error messages like:
200
+
201
+
> `useLocation()` may be used only in the context of a `<Router>` component
202
+
203
+
or
204
+
205
+
> `useNavigate()` may be used only in the context of a `<Router>` component
206
+
207
+
or
208
+
209
+
> `useRoutes()` may be used only in the context of a `<Router>` component
210
+
211
+
or
212
+
213
+
> `useHref()` may be used only in the context of a `<Router>` component.
214
+
215
+
or
216
+
217
+
> `<Route>` may be used only in the context of a `<Router>` component
218
+
219
+
These errors can happen if you added `react-router` and/or `react-router-dom` to your dependencies, and didn't use the same version as react-admin. In that case, your application has two versions of react-router, and the calls you add can't see the react-admin routing context.
220
+
221
+
You can use the `npm list react-router` and `npm list react-router-dom` commands to check which versions are installed.
222
+
223
+
If there are duplicates, you need to make sure to use only the same version as react-admin. You can deduplicate them using yarn's [resolutions](https://yarnpkg.com/configuration/manifest#resolutions) or npm’s [overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides).
224
+
225
+
```js
226
+
// in packages.json
227
+
{
228
+
// ...
229
+
"resolutions": {
230
+
"react-router-dom":"6.7.0",
231
+
"react-router":"6.7.0"
232
+
}
233
+
}
234
+
```
235
+
236
+
This may also happen inside a [Remix](https://remix.run/) application. See [Setting up react-admin for Remix](./Remix.md#setting-up-react-admin-in-remix) for instructions to overcome that problem.
`<List>` accepts a `queryOptions` prop to pass [query options](DataProviders.html#react-query-options) to the react-query client. Check react-query's [`useQuery` documentation]([query options](https://tanstack.com/query/v5/docs/react/reference/useQuery)) for the list of available options.
835
+
`<List>` accepts a `queryOptions` prop to pass [query options](DataProviders.html#react-query-options) to the react-query client. Check react-query's [`useQuery` documentation](https://tanstack.com/query/v5/docs/react/reference/useQuery) for the list of available options.
836
836
837
837
This can be useful e.g. to pass [a custom `meta`](./Actions.md#meta-parameter) to the `dataProvider.getList()` call.
0 commit comments