react-toast-notifier
v1.0.3
Published
A simple and easy to use toast notification module for react.
Downloads
114
Maintainers
Readme
react-toast-notifier
A simple and easy to use toast notification module for react.
Installation
This is a React.js module available through the
npm registry.
Installation is done using the
npm install
command:
$ npm install react-toast-notifier
Example & Usage (Success)
import React, { Fragment } from 'react';
import Notification, { notifier } from 'react-toast-notifier';
// for success message
const NotificationButton = () => {
return (
<Fragment>
<Notification />
<button onClick={() => {
notifier({ type: "success", message: "Success message", autoDismissTimeout:5000 });
}}>Toast</button>
</Fragment>
);
};
export default NotificationButton;
Example & Usage (Error)
import React, { Fragment } from 'react';
import Notification, { notifier } from 'react-toast-notifier';
// for error message
const NotificationButton = () => {
return (
<Fragment>
<Notification />
<button onClick={() => {
notifier({ type: "error", message: "Error message", autoDismissTimeout:5000 });
}}>Toast</button>
</Fragment>
);
};
export default NotificationButton;
Example & Usage (Warning)
import React, { Fragment } from 'react';
import Notification, { notifier } from 'react-toast-notifier';
// for warning message
const NotificationButton = () => {
return (
<Fragment>
<Notification />
<button onClick={() => {
notifier({ type: "warning", message: "Warning message" });
}}>Toast</button>
</Fragment>
);
};
export default NotificationButton;
Note
- autoDismissTimeout default time is 4000
- Available types : ["success", "warning", "error"]
Author
License
© Licensed under the MIT License.