Skip to content

Commit f60568a

Browse files
committed
Improve documentation
1 parent f23f8ef commit f60568a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

docs/Edit.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,14 @@ export const PostEdit = () => (
558558

559559
```jsx
560560
import { Edit, IsOffline } from 'react-admin';
561+
import { Alert } from '@mui/material';
561562

562563
export const PostEdit = () => (
563564
<Edit offline={<p>No network. Could not load the post.</p>}>
564565
<IsOffline>
565-
No network. The post data may be outdated.
566+
<Alert severity="warning">
567+
You are offline, the data may be outdated
568+
</Alert>
566569
</IsOffline>
567570
...
568571
</Edit>

docs/EditBase.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const BookEdit = () => (
9999
By default, the `<EditBase>` 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`.
100100

101101
```jsx
102-
import { EditBase } from 'ra-core';
102+
import { EditBase } from 'react-admin';
103103

104104
const PostEdit = () => (
105105
<EditBase disableAuthentication>
@@ -113,7 +113,7 @@ const PostEdit = () => (
113113
By default, `<EditBase>` 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.
114114

115115
```jsx
116-
import { EditBase } from 'ra-core';
116+
import { EditBase } from 'react-admin';
117117

118118
export const PostEdit = () => (
119119
<EditBase id="123">
@@ -129,7 +129,7 @@ export const PostEdit = () => (
129129
By default, `<EditBase>` renders nothing while checking for authentication and permissions. You can provide your own component via the `loading` prop:
130130

131131
```jsx
132-
import { EditBase } from 'ra-core';
132+
import { EditBase } from 'react-admin';
133133

134134
export const PostEdit = () => (
135135
<EditBase loading={<p>Checking for permissions...</p>}>
@@ -151,6 +151,8 @@ By default, pages using `<EditBase>` use the `undoable` mutation mode. This is p
151151
You can change this default by setting the `mutationMode` prop - and this affects both the Save and Delete buttons. For instance, to remove the ability to undo the changes, use the `optimistic` mode:
152152

153153
```jsx
154+
import { EditBase } from 'react-admin';
155+
154156
const PostEdit = () => (
155157
<EditBase mutationMode="optimistic">
156158
// ...
@@ -161,6 +163,8 @@ const PostEdit = () => (
161163
And to make the Save action blocking, and wait for the dataProvider response to continue, use the `pessimistic` mode:
162164

163165
```jsx
166+
import { EditBase } from 'react-admin';
167+
164168
const PostEdit = () => (
165169
<EditBase mutationMode="pessimistic">
166170
// ...
@@ -319,7 +323,7 @@ The default `onError` function is:
319323
By default, `<EditBase>` 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:
320324

321325
```jsx
322-
import { EditBase } from 'ra-core';
326+
import { EditBase } from 'react-admin';
323327

324328
export const PostEdit = () => (
325329
<EditBase offline={<p>No network. Could not load the post.</p>}>
@@ -331,7 +335,7 @@ export const PostEdit = () => (
331335
**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:
332336

333337
```jsx
334-
import { EditBase, IsOffline } from 'ra-core';
338+
import { EditBase, IsOffline } from 'react-admin';
335339

336340
export const PostEdit = () => (
337341
<EditBase offline={<p>No network. Could not load the post.</p>}>
@@ -439,7 +443,7 @@ const BookEdit = () => (
439443
By default, `<EditBase>` 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.
440444

441445
```jsx
442-
import { EditBase } from 'ra-core';
446+
import { EditBase } from 'react-admin';
443447

444448
export const UsersEdit = () => (
445449
<EditBase resource="users">

0 commit comments

Comments
 (0)