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
`<ReferenceField>` is useful for displaying many-to-one and one-to-one relationships, e.g. the details of a user when rendering a post authored by that user.
9
+
`<ReferenceField>` is useful for displaying many-to-one and one-to-one relationships, e.g. the details of a user when rendering a post authored by that user.
So it's a good idea to configure the `<Resource recordRepresentation>` to render related records in a meaningul way. For instance, for the `users` resource, if you want the `<ReferenceField>` to display the full name of the author:
49
+
So it's a good idea to configure the `<Resource recordRepresentation>` to render related records in a meaningful way. For instance, for the `users` resource, if you want the `<ReferenceField>` to display the full name of the author:
50
50
51
51
```jsx
52
52
<Resource
@@ -64,9 +64,9 @@ Alternately, if you pass a child component, `<ReferenceField>` will render it in
64
64
</ReferenceField>
65
65
```
66
66
67
-
This component fetches a referenced record (`users` in this example) using the `dataProvider.getMany()` method, and passes it to its child.
67
+
This component fetches a referenced record (`users` in this example) using the `dataProvider.getMany()` method, and passes it to its child.
68
68
69
-
It uses `dataProvider.getMany()` instead of `dataProvider.getOne()`[for performance reasons](#performance). When using several `<ReferenceField>` in the same page (e.g. in a `<DataTable>`), this allows to call the `dataProvider` once instead of once per row.
69
+
It uses `dataProvider.getMany()` instead of `dataProvider.getOne()`[for performance reasons](#performance). When using several `<ReferenceField>` in the same page (e.g. in a `<DataTable>`), this allows to call the `dataProvider` once instead of once per row.
70
70
71
71
## Props
72
72
@@ -97,7 +97,8 @@ By default, `<ReferenceField>` renders the `recordRepresentation` of the referen
97
97
</ReferenceField>
98
98
```
99
99
100
-
Alternatively, you can use [the `render` prop](#render) to render the referenced record in a custom way.
100
+
Alternatively, you can use [the `render` prop](#render) to render the referenced record in a custom way.
101
+
101
102
## `empty`
102
103
103
104
`<ReferenceField>` can display a custom message when the referenced record is missing, thanks to the `empty` prop.
@@ -179,6 +180,7 @@ Use the `queryOptions` prop to pass options to [the `dataProvider.getMany()` que
179
180
For instance, to pass [a custom `meta`](./Actions.md#meta-parameter):
180
181
181
182
{% raw %}
183
+
182
184
```jsx
183
185
<ReferenceField
184
186
source="user_id"
@@ -188,6 +190,7 @@ For instance, to pass [a custom `meta`](./Actions.md#meta-parameter):
188
190
<TextField source="name"/>
189
191
</ReferenceField>
190
192
```
193
+
191
194
{% endraw %}
192
195
193
196
## `reference`
@@ -246,7 +249,7 @@ To override the style of all instances of `<ReferenceField>` using the [applicat
**Note**: For prefetching to function correctly, your data provider must support [Prefetching Relationships](./DataProviders.md#prefetching-relationships). Refer to your data provider's documentation to verify if this feature is supported.
@@ -406,5 +411,6 @@ For instance, given the following `ReferenceField`:
406
411
```
407
412
408
413
React-Admin will call `canAccess` with the following parameters:
414
+
409
415
- If the `users` resource has a Show view: `{ action: "show", resource: 'posts', record: Object }`
410
-
- If the `users` resource has an Edit view: `{ action: "edit", resource: 'posts', record: Object }`
416
+
- If the `users` resource has an Edit view: `{ action: "edit", resource: 'posts', record: Object }`
0 commit comments