Skip to content

Commit bae5427

Browse files
committed
Add an example about ReferenceManyField in RecordsIterator documentation.
1 parent e887aec commit bae5427

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

docs/RecordsIterator.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,31 @@ const MostVisitedPosts = () => (
3737

3838
You can use `<RecordsIterator>` as a child of any component that provides a [`ListContext`](./useListContext.md), such as:
3939

40+
- [`<ReferenceManyField>`](./ReferenceManyField.md),
41+
- [`<ReferenceArrayField>`](./ReferenceArrayField.md),
4042
- [`<List>`](./List.md),
4143
- [`<ListGuesser>`](./ListGuesser.md),
42-
- [`<ListBase>`](./ListBase.md),
43-
- [`<ReferenceArrayField>`](./ReferenceArrayField.md),
44-
- [`<ReferenceManyField>`](./ReferenceManyField.md)
44+
- [`<ListBase>`](./ListBase.md)
45+
46+
```jsx
47+
import {
48+
ChipField,
49+
ShowBase,
50+
RecordsIterator,
51+
ReferenceManyField,
52+
SingleFieldList
53+
} from 'react-admin';
54+
55+
const PostShow = () => (
56+
<ShowBase>
57+
<ReferenceManyField reference="tags" target="post_id">
58+
<SingleFieldList>
59+
<ChipField source="name" />
60+
</SingleFieldList>
61+
</ReferenceManyField>
62+
</ShowBase>
63+
);
64+
```
4565

4666
`<RecordsIterator>` expects that data is properly loaded, without error. If you want to handle loading, error, offline and empty states, use related props on the component providing you the list context (like [`<List loading>`](./List.md), [`<ReferenceArrayField loading>`](./ReferenceArrayField.md), [`<ReferenceManyField loading>`](./ReferenceManyField.md)). You can also make use of [`<WithListContext>`](./WithListContext.md) [`loading`](./WithListContext.md#loading), [`error`](./WithListContext.md#error), [`offline`](./WithListContext.md#offline) and [`empty`](./WithListContext.md#empty) props.
4767

docs_headless/src/content/docs/RecordsIterator.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,25 @@ const MostVisitedPosts = () => (
3232

3333
You can use `<RecordsIterator>` as a child of any component that provides a [`ListContext`](./useListContext.md), such as:
3434

35-
- [`<List>`](./List.md),
36-
- [`<ListGuesser>`](./ListGuesser.md),
37-
- [`<ListBase>`](./ListBase.md),
38-
- [`<ReferenceArrayField>`](./ReferenceArrayField.md),
39-
- [`<ReferenceManyField>`](./ReferenceManyField.md)
35+
- [`<ReferenceManyFieldBase>`](./ReferenceManyFieldBase.md),
36+
- [`<ReferenceArrayFieldBase>`](./ReferenceArrayField.md),
37+
- [`<ListBase>`](./ListBase.md)
38+
39+
```jsx
40+
import { ShowBase, RecordsIterator, ReferenceManyFieldBase } from 'ra-core';
41+
42+
const PostShow = () => (
43+
<ShowBase>
44+
<ReferenceManyFieldBase reference="tags" target="post_id">
45+
<ul>
46+
<RecordsIterator
47+
render={tag => <li>#{tag.name}</li>}
48+
/>
49+
</ul>
50+
</ReferenceManyFieldBase>
51+
</ShowBase>
52+
);
53+
```
4054

4155
`<RecordsIterator>` expects that data is properly loaded, without error. If you want to handle loading, error, offline and empty states, use properties on the component providing you the list context (like [`<List loading>`](./List.md), [`<ReferenceArrayField loading>`](./ReferenceArrayField.md), [`<ReferenceManyField loading>`](./ReferenceManyField.md)). You can also make use of [`<WithListContext>`](./WithListContext.md) [`loading`](./WithListContext.md#loading), [`error`](./WithListContext.md#error), [`offline`](./WithListContext.md#offline) and [`empty`](./WithListContext.md#empty) props.
4256

0 commit comments

Comments
 (0)