From 8464c3ee0637eec9fa9bb80267909569fda989ba Mon Sep 17 00:00:00 2001 From: asvarcas <asvarcas@etriek.com.uy> Date: Fri, 11 Nov 2022 15:04:56 -0300 Subject: [PATCH 1/3] Fix useReference hook docs --- docs/Reference.md | 2 +- docs/Upgrade.md | 2 +- docs/useGetOne.md | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/Reference.md b/docs/Reference.md index a60f70ed1cc..fe7488acbdb 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -200,7 +200,7 @@ title: "Reference" * [`useRecordContext`](./useRecordContext.md) * `useRecordSelection` * [`useRedirect`](./useRedirect.md) -* [`useReference`](./useGetOne.md#aggregating-getone-calls) +* [`useReference`](./useGetOne.md#usereference) * `useReferenceArrayFieldController` * `useReferenceArrayInputController` * `useReferenceInputController` diff --git a/docs/Upgrade.md b/docs/Upgrade.md index 7bf50a09db2..29db3011dd4 100644 --- a/docs/Upgrade.md +++ b/docs/Upgrade.md @@ -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` instead) - Removed `<ReferenceArrayFieldController>` (use `useReferenceArrayFieldController` instead) - Removed `<ReferenceManyFieldController>` (use `useReferenceManyFieldController` instead) - Removed `<ReferenceInputController>` (use `useReferenceInputController` instead) diff --git a/docs/useGetOne.md b/docs/useGetOne.md index 9be0d40e721..5fb3b91d098 100644 --- a/docs/useGetOne.md +++ b/docs/useGetOne.md @@ -90,7 +90,9 @@ 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. +## `useReference` + +As `useGetManyAggregate` 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. ```diff -import { useGetOne, useRecordContext } from 'react-admin'; From 0a7f031106643b972db8287eb9b8de0bbbb360cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Zaninotto?= <fzaninotto@gmail.com> Date: Mon, 14 Nov 2022 09:53:40 +0100 Subject: [PATCH 2/3] Do not introduce non-dataProvider hook in a data provider hook doc --- docs/Reference.md | 2 +- docs/Upgrade.md | 2 +- docs/useGetOne.md | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/Reference.md b/docs/Reference.md index fe7488acbdb..a60f70ed1cc 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -200,7 +200,7 @@ title: "Reference" * [`useRecordContext`](./useRecordContext.md) * `useRecordSelection` * [`useRedirect`](./useRedirect.md) -* [`useReference`](./useGetOne.md#usereference) +* [`useReference`](./useGetOne.md#aggregating-getone-calls) * `useReferenceArrayFieldController` * `useReferenceArrayInputController` * `useReferenceInputController` diff --git a/docs/Upgrade.md b/docs/Upgrade.md index 29db3011dd4..34eac7381b4 100644 --- a/docs/Upgrade.md +++ b/docs/Upgrade.md @@ -3274,7 +3274,7 @@ Use the `<Title>` component instead. ### Removed Deprecated Elements - Removed `<BulkDeleteAction>` (use `<BulkDeleteButton>` instead) -- Removed `<ReferenceFieldController>` (use `useReference` 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) diff --git a/docs/useGetOne.md b/docs/useGetOne.md index 5fb3b91d098..c54938faf56 100644 --- a/docs/useGetOne.md +++ b/docs/useGetOne.md @@ -90,8 +90,6 @@ 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. -## `useReference` - As `useGetManyAggregate` 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. ```diff From 7a631be00bd03835409fdf75ffee3e7427233ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Zaninotto?= <fzaninotto@gmail.com> Date: Mon, 14 Nov 2022 09:54:37 +0100 Subject: [PATCH 3/3] Fix typo --- docs/useGetOne.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/useGetOne.md b/docs/useGetOne.md index c54938faf56..45bba2e8886 100644 --- a/docs/useGetOne.md +++ b/docs/useGetOne.md @@ -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 `useGetManyAggregate` 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';