Skip to content

Commit eb33ba4

Browse files
authored
Merge pull request #8369 from marmelab/fix-doc-notification
[Doc] Add missing `Admin`'s notification prop
2 parents 08bf9a7 + d63834a commit eb33ba4

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

docs/Admin.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Here are all the props accepted by the component:
4646
- [`ready`](#ready)
4747
- [`requireAuth`](#requireauth)
4848
- [`store`](#store)
49+
- [`notification`](#notification)
4950

5051
## `dataProvider`
5152

@@ -399,20 +400,20 @@ const App = () => (
399400
);
400401
```
401402

402-
Your custom layout can simply extend [the default `<Layout>` component](./Layout.md) if you only want to override the appBar, the menu, the notification component, or the error page. For instance:
403+
Your custom layout can simply extend [the default `<Layout>` component](./Layout.md) if you only want to override the appBar, the menu, or the error page. For instance:
403404

404405
```jsx
405406
// in src/MyLayout.js
406407
import { Layout } from 'react-admin';
407408
import MyAppBar from './MyAppBar';
408409
import MyMenu from './MyMenu';
409-
import MyNotification from './MyNotification';
410+
import MyError from './MyError';
410411

411412
const MyLayout = (props) => <Layout
412413
{...props}
413414
appBar={MyAppBar}
414415
menu={MyMenu}
415-
notification={MyNotification}
416+
error={MyError}
416417
/>;
417418

418419
export default MyLayout;
@@ -533,6 +534,33 @@ const App = () => (
533534
);
534535
```
535536

537+
## `notification`
538+
539+
You can override the notification component, for instance to change the notification duration. A common use case is to change the `autoHideDuration`, and force the notification to remain on screen longer than the default 4 seconds. For instance, to create a custom Notification component with a 5 seconds default:
540+
541+
```jsx
542+
// in src/MyNotification.js
543+
import { Notification } from 'react-admin';
544+
545+
const MyNotification = () => <Notification autoHideDuration={5000} />;
546+
547+
export default MyNotification;
548+
```
549+
550+
To use this custom notification component, pass it to the `<Admin>` component as the `notification` prop:
551+
552+
```jsx
553+
// in src/App.js
554+
import MyNotification from './MyNotification';
555+
import dataProvider from './dataProvider';
556+
557+
const App = () => (
558+
<Admin notification={MyNotification} dataProvider={dataProvider}>
559+
// ...
560+
</Admin>
561+
);
562+
```
563+
536564
## Declaring resources at runtime
537565

538566
You might want to dynamically define the resources when the app starts. To do so, you have two options: using a function as `<Admin>` child, or unplugging it to use a combination of `AdminContext` and `<AdminUI>` instead.

docs/Theming.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,13 @@ const App = () => (
10091009

10101010
## Notifications
10111011

1012-
You can override the notification component, for instance to change the notification duration. It defaults to 4000, i.e. 4 seconds, and you can override it using the `autoHideDuration` prop. For instance, to create a custom Notification component with a 5 seconds default:
1012+
You can override the notification component, for instance to change the notification duration. A common use case is to change the `autoHideDuration`, and force the notification to remain on screen longer than the default 4 seconds. For instance, to create a custom Notification component with a 5 seconds default:
10131013

10141014
```jsx
10151015
// in src/MyNotification.js
10161016
import { Notification } from 'react-admin';
10171017

1018-
const MyNotification = props => <Notification {...props} autoHideDuration={5000} />;
1018+
const MyNotification = () => <Notification autoHideDuration={5000} />;
10191019

10201020
export default MyNotification;
10211021
```

0 commit comments

Comments
 (0)