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
Copy file name to clipboardExpand all lines: docs/ReferenceArrayField.md
+94Lines changed: 94 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,10 @@ You can change how the list of related records is rendered by passing a custom c
87
87
|`reference`| Required |`string`| - | The name of the resource for the referenced records, e.g. 'tags' |
88
88
|`children`| Optional *|`ReactNode`|`<SingleFieldList>`| One or several elements that render a list of records based on a `ListContext`|
89
89
|`render`| Optional *|`(listContext) => Element`|`<SingleFieldList>`| A function that takes a list context and render a list of records |
90
+
|`empty`| Optional |`ReactNode`| - | The component to render when the related records list is empty |
91
+
|`error`| Optional |`ReactNode`| - | The component to render when an error occurs while fetching the related records |
90
92
|`filter`| Optional |`Object`| - | Filters to use when fetching the related records (the filtering is done client-side) |
93
+
|`loading`| Optional |`ReactNode`|`<LinearProgress>`| The component to render while fetching the related records |
91
94
|`offline`| Optional |`ReactNode`|`<Offline variant="inline" />`| The component to render when there is no connectivity and the record isn't in the cache |
92
95
|`pagination`| Optional |`ReactNode`| - | Pagination element to display pagination controls. empty by default (no pagination) |
93
96
|`perPage`| Optional |`number`| 1000 | Maximum number of results to display |
By default, `<ReferenceArrayField>` renders its children when the related records list is empty. You can customize what is rendered by providing your own component via the `empty` prop:
You can also have `<ReferenceArrayField>` render nothing in that case by setting the prop to `null`:
213
+
214
+
```jsx
215
+
<ReferenceArrayField
216
+
source="tag_ids"
217
+
reference="tags"
218
+
empty={null}
219
+
/>
220
+
```
221
+
222
+
## `error`
223
+
224
+
By default, `<ReferenceArrayField>` renders its children when an error occurs while fetching the related records. You can customize what is rendered by providing your own component via the `error` prop:
You can also have `<ReferenceArrayField>` render nothing in that case by setting the prop to `null`:
243
+
244
+
```jsx
245
+
<ReferenceArrayField
246
+
source="tag_ids"
247
+
reference="tags"
248
+
error={null}
249
+
/>
250
+
```
251
+
189
252
## `filter`
190
253
191
254
`<ReferenceArrayField>` fetches all the related records, and displays them all, too. You can use the `filter` prop to filter the list of related records to display (this works by filtering the records client-side, after the fetch).
@@ -228,6 +291,37 @@ React-admin uses [the i18n system](./Translation.md) to translate the label, so
By default, `<ReferenceArrayField>` renders a `<LinearProgress>` component while fetching the related records. You can customize what is rendered by providing your own component via the `loading` prop:
You can also have `<ReferenceArrayField>` render nothing in that case by setting the prop to `null`:
316
+
317
+
```jsx
318
+
<ReferenceArrayField
319
+
source="tag_ids"
320
+
reference="tags"
321
+
loading={null}
322
+
/>
323
+
```
324
+
231
325
## `offline`
232
326
233
327
By default, `<ReferenceArrayField>` renders the `<Offline variant="inline">` when there is no connectivity and the records haven't been cached yet. You can provide your own component via the `offline` prop:
0 commit comments