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
`<ReferenceArrayFieldBase>` expects a `reference` attribute, which specifies the resource to fetch for the related records. It also expects a `source` attribute, which defines the field containing the list of ids to look for in the referenced resource.
@@ -106,11 +106,10 @@ You can access the list context using the `useListContext` hook.
`<ReferenceFieldBase>` fetches the data, puts it in a [`RecordContext`](./useRecordContext.md), and its up to its children to handle the rendering by accessing the ReferencingContext using the useReferenceFieldContext hook.
40
-
41
-
This component fetches a referenced record (`users` in this example) using the `dataProvider.getMany()` method, and passes it to the `ReferenceFieldContext`.
`<ReferenceFieldBase>` fetches the data, puts it in a [`RecordContext`](./useRecordContext.md), and its up to its children to handle the rendering by accessing the `ReferencingContext` using the `useReferenceFieldContext` hook.
59
+
68
60
It uses `dataProvider.getMany()` instead of `dataProvider.getOne()`[for performance reasons](#performance). When using several `<ReferenceFieldBase>` in the same page (e.g. in a `<DataTable>`), this allows to call the `dataProvider` once instead of once per row.
69
61
70
62
## Props
@@ -74,7 +66,7 @@ It uses `dataProvider.getMany()` instead of `dataProvider.getOne()` [for perform
74
66
|`source`| Required |`string`| - | Name of the property to display |
75
67
|`reference`| Required |`string`| - | The name of the resource for the referenced records, e.g. 'posts' |
76
68
|`children`| Optional |`ReactNode`| - | React component to render the referenced record. |
77
-
|`render`| Optional |`(context) => ReactNode`| - | Function that takes the referenceFieldContext and render the referenced record. |
69
+
|`render`| Optional |`(context) => ReactNode`| - | Function that takes the referenceFieldContext and renders the referenced record. |
78
70
|`empty`| Optional |`ReactNode`| - | What to render when the field has no value or when the reference is missing |
Use the `queryOptions` prop to pass options to [the `dataProvider.getMany()` query](./useGetOne.md#aggregating-getone-calls) that fetches the referenced record.
@@ -225,6 +185,7 @@ For instance, if the `posts` resource has a `user_id` field, set the `reference`
225
185
...
226
186
</ReferenceFieldBase>
227
187
```
188
+
228
189
## `sortBy`
229
190
230
191
By default, when used in a `<Datagrid>`, and when the user clicks on the column header of a `<ReferenceFieldBase>`, react-admin sorts the list by the field `source`. To specify another field name to sort by, set the `sortBy` prop.
@@ -234,6 +195,7 @@ By default, when used in a `<Datagrid>`, and when the user clicks on the column
0 commit comments