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
|`sort`| Optional |`{ field: String, order: 'ASC' or 'DESC' }`|`{ field: 'id', order: 'ASC' }`| Used to order referenced records |
69
69
70
+
`*` You must provide either `children` or `render`.
71
+
70
72
`<ReferenceOneField>` also accepts the [common field props](./Fields.md#common-field-props).
71
73
72
74
## `children`
@@ -81,34 +83,6 @@ For instance, if you want to render both the genre and the ISBN for a book:
81
83
</ReferenceOneField>
82
84
```
83
85
84
-
85
-
## `render`
86
-
87
-
Alternatively to children you can pass a `render` function prop to `<ReferenceOneFieldBase>`. The `render` function prop will receive the `ReferenceFieldContext` as its argument, allowing to inline the render logic.
88
-
When receiving a `render` function prop the `<ReferenceOneFieldBase>` component will ignore the children property.
Use `empty` to customize the text displayed when the related record is empty.
@@ -213,6 +187,38 @@ For instance, if you want to display the details of a given book, the `reference
213
187
</ReferenceOneField>
214
188
```
215
189
190
+
## `render`
191
+
192
+
Alternatively to `children`, you can pass a `render` prop to `<ReferenceOneField>`. It will receive the `ReferenceFieldContext` as its argument, and should return a React node.
193
+
194
+
This allows to inline the render logic for the related record.
You can also use `<ReferenceOneField>` in a one-to-many relationship. In that case, the first record will be displayed. This is where the `sort` prop comes in handy. It allows you to select the appropriate record to display.
0 commit comments