react-notification-manager
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Setup

Typical usage involves wrapping your entire app with a <NotificationProvider>:

import * as React from "react";
import ReactDOM from "react-dom";
import { NotificationProvider } from "react-notification-manager";
import App from "./App";
 
ReactDOM.render(
    <NotificationProvider>
        <App />
    </NotificationProvider>,
    document.getElementById("root")
);

Now you can use useNotificationManager to create notifications.

import * as React from "react";
import { useNotificationManager } from "react-notification-manager";
 
// Your own Dialog component
import Dialog from "./your-app/dialog";
 
function App() {
    const { createNotification } = useNotificationManager();
 
    return (
        <button
            onClick={createNotification(({ close }) => (
                <Dialog onClose={close} />
            ))}>
            Open Dialog
        </button>
    );
}

Package Sidebar

Install

npm i react-notification-manager

Weekly Downloads

191

Version

2.0.0

License

MIT

Unpacked Size

27.1 kB

Total Files

26

Last publish

Collaborators

  • ericmantooth