Skip to content

Commit

Permalink
Merge pull request #8385 from marmelab/fix-use-reference
Browse files Browse the repository at this point in the history
[Doc] Fix `useReference` hook docs
  • Loading branch information
fzaninotto authored Nov 14, 2022
2 parents eac7c59 + 7a631be commit 00ffc81
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -3274,7 +3274,7 @@ Use the `<Title>` component instead.
### Removed Deprecated Elements

- Removed `<BulkDeleteAction>` (use `<BulkDeleteButton>` instead)
- Removed `<ReferenceFieldController>` (use `useReferenceFieldController` instead)
- Removed `<ReferenceFieldController>` (use [`useReference`](./useGetOne.md#aggregating-getone-calls) instead)
- Removed `<ReferenceArrayFieldController>` (use `useReferenceArrayFieldController` instead)
- Removed `<ReferenceManyFieldController>` (use `useReferenceManyFieldController` instead)
- Removed `<ReferenceInputController>` (use `useReferenceInputController` instead)
Expand Down
2 changes: 1 addition & 1 deletion docs/useGetOne.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const UserProfile = () => {

This results in less calls to the dataProvider. For instance, if the `<UserProfile>` component above is rendered in a `<Datagrid>`, it will only make one call to `dataProvider.getMany()` for the entire list instead of one call to `dataProvider.getOne()` per row.

As this hook is often used to fetch references, react-admin exposes a `useReference` hook, which avoids doing the array conversion manually. It's an application hook rather than a data provider hook, so its syntax is a bit different. Prefer `useReference` to `useGetManyAggregate` when you use `useGetOne` to fetch a reference.
As `useGetManyAggregate` is often used to fetch references, react-admin exposes a `useReference` hook, which avoids doing the array conversion manually. It's an application hook rather than a data provider hook, so its syntax is a bit different. Prefer `useReference` to `useGetManyAggregate` when you use `useGetOne` to fetch a reference.

```diff
-import { useGetOne, useRecordContext } from 'react-admin';
Expand Down

0 comments on commit 00ffc81

Please sign in to comment.