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
| `children` | Optional | `ReactNode` | | The components rendering the record fields
66
-
| `render` | Optional | `(props: ShowControllerResult<RecordType>) => ReactNode` | | Alternative to children, a function that takes the ShowController context and renders the form
66
+
| `render`| Optional | `(props: ShowControllerResult<RecordType>) => ReactNode` | | Alternative to children, a function that takes the ShowController context and renders the form
67
67
| `disable Authentication` | Optional | `boolean` | | Set to `true` to disable the authentication check
68
-
| `empty WhileLoading` | Optional | `boolean` | | Set to `true` to return `null` while the list is loading
69
68
| `id` | Optional | `string` | | The record identifier. If not provided, it will be deduced from the URL
69
+
| `loading` | Optional | `ReactNode` | | The component to render while checking for authentication and permissions
70
+
| `offline` | Optional | `ReactNode` | | The component to render when there is no connectivity and the record isn't in the cache
70
71
| `queryOptions` | Optional | `object` | | The options to pass to the `useQuery` hook
71
72
| `resource` | Optional | `string` | | The resource name, e.g. `posts`
72
73
@@ -139,6 +140,8 @@ const BookShow = () => (
139
140
By default, the `<ShowBase>` component will automatically redirect the user to the login page if the user is not authenticated. If you want to disable this behavior and allow anonymous access to a show page, set the `disableAuthentication` prop to `true`.
140
141
141
142
```jsx
143
+
import { ShowBase } from'ra-core';
144
+
142
145
constPostShow= () => (
143
146
<ShowBase disableAuthentication>
144
147
...
@@ -151,6 +154,8 @@ const PostShow = () => (
151
154
By default, `<ShowBase>` deduces the identifier of the record to show from the URL path. So under the `/posts/123/show` path, the `id` prop will be `123`. You may want to force a different identifier. In this case, pass a custom `id` prop.
**Tip**: Pass both a custom `id` and a custom `resource` prop to use `<ShowBase>` independently of the current URL. This even allows you to use more than one `<ShowBase>` component in the same page.
162
167
168
+
## `loading`
169
+
170
+
By default, `<ShowBase>` renders nothing while checking for authentication and permissions. You can provide your own component via the `loading` prop:
171
+
172
+
```jsx
173
+
import { ShowBase } from'ra-core';
174
+
175
+
exportconstPostShow= () => (
176
+
<ShowBase loading={<p>Checking for permissions...</p>}>
177
+
...
178
+
</ShowBase>
179
+
);
180
+
```
181
+
182
+
## `offline`
183
+
184
+
By default, `<ShowBase>` renders nothing when there is no connectivity and the record hasn't been cached yet. You can provide your own component via the `offline` prop:
185
+
186
+
```jsx
187
+
import { ShowBase } from'ra-core';
188
+
189
+
exportconstPostShow= () => (
190
+
<ShowBase offline={<p>No network. Could not load the post.</p>}>
191
+
...
192
+
</ShowBase>
193
+
);
194
+
```
195
+
196
+
**Tip**: If the record is 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:
197
+
198
+
```jsx
199
+
import { ShowBase, IsOffline } from'ra-core';
200
+
201
+
exportconstPostShow= () => (
202
+
<ShowBase offline={<p>No network. Could not load the post.</p>}>
203
+
<IsOffline>
204
+
No network. The post data may be outdated.
205
+
</IsOffline>
206
+
</ShowBase>
207
+
);
208
+
```
209
+
163
210
## `queryOptions`
164
211
165
212
`<ShowBase>` accepts a `queryOptions` prop to pass options to the react-query client.
@@ -210,6 +257,8 @@ The default `onError` function is:
210
257
By default, `<ShowBase>` operates on the current `ResourceContext` (defined at the routing level), so under the `/posts/1/show` path, the `resource` prop will be `posts`. You may want to force a different resource. In this case, pass a custom `resource` prop, and it will override the `ResourceContext` value.
0 commit comments