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
70
@@ -156,6 +157,30 @@ You can also set the `link` prop to a string, which will be used as the link typ
156
157
</ReferenceOneField>
157
158
```
158
159
160
+
161
+
## `offline`
162
+
163
+
Use `offline` to customize the text displayed when the related record is empty because there is no network connectivity.
164
+
165
+
```jsx
166
+
<ReferenceOneField label="Details" reference="book_details" target="book_id" offline="No network, could not fetch data">
167
+
...
168
+
</ReferenceOneField>
169
+
```
170
+
171
+
`offline` also accepts a `ReactNode`.
172
+
173
+
```jsx
174
+
<ReferenceOneField
175
+
label="Details"
176
+
reference="book_details"
177
+
target="book_id"
178
+
offline={<p>No network, could not fetch data</p>}
179
+
>
180
+
...
181
+
</ReferenceOneField>
182
+
```
183
+
159
184
## `queryOptions`
160
185
161
186
`<ReferenceOneField>` uses `react-query` to fetch the related record. You can set [any of `useQuery` options](https://tanstack.com/query/v5/docs/react/reference/useQuery) via the `queryOptions` prop.
|`sort`| Optional |`{ field: String, order: 'ASC' or 'DESC' }`|`{ field: 'id', order: 'ASC' }`| Used to order referenced records |
83
84
@@ -122,39 +123,6 @@ const BookDetails = () => {
122
123
}
123
124
```
124
125
125
-
## `render`
126
-
127
-
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.
128
-
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.
@@ -228,6 +196,29 @@ You can also set the `link` prop to a string, which will be used as the link typ
228
196
```
229
197
{% endraw %}
230
198
199
+
## `offline`
200
+
201
+
Use `offline` to customize the text displayed when the related record is empty because there is no network connectivity.
202
+
203
+
```jsx
204
+
<ReferenceOneFieldBase label="Details" reference="book_details" target="book_id" offline="No network, could not fetch data">
205
+
...
206
+
</ReferenceOneFieldBase>
207
+
```
208
+
209
+
`offline` also accepts a `ReactNode`.
210
+
211
+
```jsx
212
+
<ReferenceOneFieldBase
213
+
label="Details"
214
+
reference="book_details"
215
+
target="book_id"
216
+
offline={<p>No network, could not fetch data</p>}
217
+
>
218
+
...
219
+
</ReferenceOneFieldBase>
220
+
```
221
+
231
222
## `queryOptions`
232
223
233
224
`<ReferenceOneFieldBase>` uses `react-query` to fetch the related record. You can set [any of `useQuery` options](https://tanstack.com/query/v5/docs/react/reference/useQuery) via the `queryOptions` prop.
@@ -247,6 +238,39 @@ For instance, if you want to disable the refetch on window focus for this query,
247
238
```
248
239
{% endraw %}
249
240
241
+
## `render`
242
+
243
+
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.
244
+
When receiving a `render` function prop the `<ReferenceOneFieldBase>` component will ignore the children property.
0 commit comments