juliancwirko / react-s-alert

Alerts / Notifications for React with rich configuration options
https://www.npmjs.com/package/react-s-alert
MIT License
649 stars 75 forks source link

How do you get the AlertId? #32

Closed pdfabbro closed 7 years ago

pdfabbro commented 7 years ago

Hi, how do you get the alertid in order to pass it to the close method? The documentation says "sAlert methods will return the already created alertId.", but I'm not sure how to get this id and pass it to the close method.

pdfabbro commented 7 years ago

Never mind. I guess it wouldn't make sense to have a close button that selects one alert and closes it other than the X button which is located on each alert.

juliancwirko commented 7 years ago

If you need current alertId you can do something like:

(...)
const alertId = Alert.warning('Test message 1', {...optionsHere});
(...)
Alert.close(alertId);
pdfabbro commented 7 years ago

Thanks, I tried that and it didn't work but that was because I was doing it inside a return statement. I moved it to the onclick of callling the function and it worked.

juliancwirko commented 7 years ago

hi, I'll close the isssue for now, but feel free to comment it here if there is something to discuss.