minhtranite / react-notifications

Notification component for ReactJS
https://www.npmjs.com/package/react-notifications
287 stars 65 forks source link

Require provision of removeNotification() #17

Open ashishd751 opened 7 years ago

ashishd751 commented 7 years ago

Hey @minhtranite , Can you please provide us with a solution to remove the notification programatically. Currently, the notification gets removed only after the time-out or onClick of the callback function. We need a provision that allows us to remove the notification at any time (even onClick of the notification).

Thank you.

rodrix commented 7 years ago

Hey guy, what's up?!

I do this:

NotificationManager.create({
  id: 1,
  type: "YOUR TYPE: INFO, ERROR, WARNING, SUCCESS",
  message: "Boladona Message",
  title: "Boladão Title",
  timeOut: 0,
  onClick: () => {
      console.log("Clicked");
  }
});

setTimeout(function () {
  NotificationManager.remove({id: 1});
}, 2000);

The trick is the ID attribute. ;D

Hope this help!