1.1.0 • Published 6 years ago

@breathecode/react-notifier v1.1.0

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

React Notifier

React component for notifications on the fron end.

Installation

$ npm i --save @breathecode/react-notifier

How to use it

1) Add the Notifier tag anywhere in your web app

ReactDOM.render(
    <Notifier />,
    document.querySelector('#root')
);

2) Call the Notify function from anywhere else

//notify for error
Notify.error("Hey! There is an error");

//notify for success
Notify.success("Everything is cool my brother");

Customize notification

2) Call the Notify function from anywhere else

    
    const ModalComponent = ({ onConfirm }) => 
        <div>
            <h1>Are you sure?</h1>
            <button onClick={()=>onConfirm(true)}>Yes</button>
            <button onClick={()=>onConfirm(false)}>No</button>
        </div>;

    /**
     * @param1: Wrapper css class 
     * @param2: Component to render it
     * @param3: callback when answered
     * @param4: timeout in millisecons (null for no timout)
    **/
    let noti = Notify.add('info', ModalComponent, (answer)=>{
        
        console.log("The user answer is: ", answer);
        noti.remove();
        
    }, 9999999999999);
1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago