1.1.3 • Published 3 years ago

react-toasted-notifications v1.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

React toasted notification using hook.

Installation:

npm i react-toaster-notification --save

# or

yarn add react-toaster-notification

Configuration

On the root of the application.

import { Notification } from "../src/";
// rest of the import

const App = (props) => {
  return (
    <Router>
      <App />
      <Notification />
    </Router>
  );
};

When you want to use a notification.

import { useNotification } from "../src/";
// rest of the import

export const Implementation = (props) => {
  const [Message, action] = useNotification();

  const handleNotification = () => {
    action.addNotification({
      title: "Warning",
      message: "Choose more strong password",
      type: "warning",
    });
  };

  return (
    <p>
      <button onClick={handleNotification}>Click</button>
    </p>
  );
};

List of the props global Notification component.

propdefaulttypefunction
timeout5000NumberGlobal timeout value for notification
colors{...}ObjectSee possible default object.
positionbottomRightStringSee possible value below.
leftundefinedStringPadding left
rightundefinedStringPadding right
bottomundefinedStringPadding bottom
topundefinedStringPadding top
  • Possible value for position: topRight, bottomRight, topLeft, bottomLeft
  • default color object:
colors: {
    error: "#E44D4D",
    warning: "#F1AC12",
    info: "#3090FF",
    success: "#72C51B",
  }

Configuration object for notification

keyvalueOptions
titleString" "
messageString" "
typeStringpossible options: info, success, error, success
timeoutNumberdefault: 5000
OnClosefunctionfunction when notification is removed