react-toast-notifier

1.0.3 • Public • Published

react-toast-notifier CI status

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

Rohan Shukla GitHub LinkedIn

License

© Licensed under the MIT License.

Package Sidebar

Install

npm i react-toast-notifier

Weekly Downloads

18

Version

1.0.3

License

MIT

Unpacked Size

871 kB

Total Files

4

Last publish

Collaborators

  • rohanshukla