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/ReferenceManyField.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,7 @@ This example leverages [`<SingleFieldList>`](./SingleFieldList.md) to display an
96
96
|`debounce`| Optional |`number`| 500 | debounce time in ms for the `setFilters` callbacks |
97
97
|`empty`| Optional |`ReactNode`| - | Element to display when there are no related records. |
98
98
|`filter`| Optional |`Object`| - | Filters to use when fetching the related records, passed to `getManyReference()`|
99
+
|`offline`| Optional |`ReactNode`| - | Element to display when there are no related records because of lack of network connectivity. |
99
100
|`pagination`| Optional |`Element`| - | Pagination element to display pagination controls. empty by default (no pagination) |
100
101
|`perPage`| Optional |`number`| 25 | Maximum number of referenced records to fetch |
101
102
|`queryOptions`| Optional |[`UseQuery Options`](https://tanstack.com/query/v3/docs/react/reference/useQuery)|`{}`|`react-query` options for the `getMany` query |
@@ -307,6 +308,49 @@ React-admin uses [the i18n system](./Translation.md) to translate the label, so
307
308
</ReferenceManyField>
308
309
```
309
310
311
+
## `offline`
312
+
313
+
By default, `<ReferenceManyField>` 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:
314
+
315
+
```jsx
316
+
<ReferenceManyField
317
+
reference="books"
318
+
target="author_id"
319
+
offline="Offline, could not load data"
320
+
>
321
+
...
322
+
</ReferenceManyField>
323
+
```
324
+
325
+
`offline` also accepts a `ReactNode`.
326
+
327
+
```jsx
328
+
<ReferenceManyField
329
+
reference="books"
330
+
target="author_id"
331
+
empty={<Alert severity="warning">Offline, could not load data</Alert>}
332
+
>
333
+
...
334
+
</ReferenceManyField>
335
+
```
336
+
337
+
**Tip**: If the records are in the Tanstack Query cache but you want to warn the user that they may see an outdated version, you can use the `<IsOffline>` component:
338
+
339
+
```jsx
340
+
<ReferenceManyField
341
+
reference="books"
342
+
target="author_id"
343
+
empty={<Alert severity="warning">Offline, could not load data</Alert>}
344
+
>
345
+
<IsOffline>
346
+
<Alert severity="warning">
347
+
You are offline, the data may be outdated
348
+
</Alert>
349
+
</IsOffline>
350
+
...
351
+
</ReferenceManyField>
352
+
```
353
+
310
354
## `pagination`
311
355
312
356
If you want to allow users to paginate the list, pass a `<Pagination>` element as the `pagination` prop:
0 commit comments