minhtranite / react-notifications

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

Notifications popping up in the wrong sub-window in Material Ui Dialogs #40

Open Claim0013 opened 6 years ago

Claim0013 commented 6 years ago

I am using Material Ui and in one particular window I have a Dialog that opens another Dialog where if something happens a notification goes off.

Now it seems as if the notification has its root in the first Dialog, which is wrong. It should be in the second Dialog.

Here's a screenshot of what this looks like.

Any help appreciated.

Claim0013 commented 6 years ago

Nevermind, solved it myself.

CelcoNeto commented 4 years ago

How did you solve it? I have the same problem. @Claim0013

Claim0013 commented 4 years ago

How did you solve it? I have the same problem. @Claim0013

Hey I'm really sorry but this was so long ago - I don't remember how I solved it but I can hint you over to react-toastify. You just add that once in your index.js and then call it as toast.info/error/success in the file you want the message.

The issue you're running into may be related to importing the component itself (not the method) in multiple files so maybe look out for that.

For instance with react-toastify you only do import { ToastContainer } from 'react-toastify'; once in index.js and then just use toast.info wherever you want.

So just do import {NotificationContainer, NotificationManager} from 'react-notifications'; once in a dedicated file only for messages and import the methods from there.

Hope that helps.