Skip to content

Commit bb15078

Browse files
committed
Merge branch 'master' into next
2 parents 6fcceb4 + 57d1e99 commit bb15078

8 files changed

Lines changed: 465 additions & 449 deletions

File tree

docs/Admin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ React-admin uses [React Query](https://tanstack.com/query/v5/) to fetch, cache a
906906
* The query is optionally configured with a refetch interval
907907
* 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.
908908
* 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.
910910
* 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`.
911911

912912
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:

docs/DataProviderWriting.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ export default {
440440
};
441441
```
442442

443+
**Note**: Throwing an `httpError` in your `dataProvider` will result in a notify popup appearing in your admin UI.
444+
443445
## Handling Authentication
444446

445447
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.

docs/DataProviders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ React-admin uses [React Query](https://tanstack.com/query/v5/) to fetch, cache,
6868
* The query is optionally configured with a refetch interval
6969
* 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.
7070
* 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.
7272
* 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`.
7373

7474
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:

docs/DatagridAG.md

Lines changed: 389 additions & 442 deletions
Large diffs are not rendered by default.

docs/FAQ.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ title: "FAQ"
66
# FAQ
77

88
- [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)
1010
- [How can I customize forms depending on its inputs values?](#how-can-i-customize-forms-depending-on-its-inputs-values)
1111
- [UI in production build is empty or broken](#ui-in-production-build-is-empty-or-broken)
1212
- [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)
1315

1416
## Can I have custom identifiers/primary keys for my resources?
1517

@@ -118,7 +120,7 @@ const dataProvider = {
118120
};
119121
```
120122

121-
## I get warning about unique key for child in array
123+
## I get a warning about unique key for child in array
122124

123125
When displaying a `Datagrid` component, you get the following warning:
124126

@@ -167,3 +169,68 @@ export const MyMenu = () => (
167169
</Menu>
168170
);
169171
```
172+
173+
## I get an error about control being null
174+
175+
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.

docs/List.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ export const PostList = () => (
832832

833833
## `queryOptions`
834834

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]([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.
836836

837837
This can be useful e.g. to pass [a custom `meta`](./Actions.md#meta-parameter) to the `dataProvider.getList()` call.
838838

packages/ra-core/src/dataProvider/useGetOne.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const useGetOne = <RecordType extends RaRecord = any, ErrorType = Error>(
7171
queryKey: [resource, 'getOne', { id: String(id), meta }],
7272
queryFn: queryParams =>
7373
id == null
74-
? new Promise(() => {})
74+
? Promise.reject('useGetOne: id cannot be null')
7575
: dataProvider
7676
.getOne<RecordType>(resource, {
7777
id,

packages/ra-ui-materialui/src/detail/editFieldTypes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')}
7474
referenceArray: {
7575
component: ReferenceArrayInput,
7676
representation: (props: ReferenceArrayInputProps) =>
77-
`<ReferenceArrayInput source="${props.source}" reference="${props.reference}"><TextInput source="id" /></ReferenceArrayInput>`,
77+
`<ReferenceArrayInput source="${props.source}" reference="${props.reference}" />`,
7878
},
7979
referenceArrayChild: {
8080
component: (

0 commit comments

Comments
 (0)