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] Fix useReference hook docs #8385

Merged
merged 3 commits into from
Nov 14, 2022
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
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