juliancwirko/react-s-alert

How do you get the AlertId?

pdfabbro opened this issue · 4 comments

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.

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.

If you need current alertId you can do something like:

(...)
const alertId = Alert.warning('Test message 1', {...optionsHere});
(...)
Alert.close(alertId);

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.

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