juliancwirko / react-s-alert

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

How to display only one similar error message out of multiple similar error messages #72

Closed pavangond closed 6 years ago

pavangond commented 6 years ago

In my react app, i have 4 react components in all of them i am refering react-s-alert . for some reason i am getting network issue while displaying those errors using react-s-alert all are displaying network failed error message(total 4 similar error messages).

  1. All four messages are similar, so now i want to display only one out of those similar error messages.
  2. if i get 4 different error messages all 4 should display.

I refered doc i didn't get any idea

Is it possible or not..?

juliancwirko commented 6 years ago

Sorry, I need reproduction repo for that because I think I don't understand the problem.

pavangond commented 6 years ago

ok,

i have 3 click buttons, if i click on them, we will get error notifications

click

If i click on all buttons they will produce same error message (unique error message i.e Network error) . similar_error

all the 3 error messages are same, instead of displaying all the 3 messages i want to display only 1 messages(bcz all convey same information).

we want like this :-

Only if error messages are same then onclick of click1 or click2 or click3 we should show 1 message

similar

If error messages are not same

diff

How can i achieve it or Is there any features we have, to display single error message instead of displaying multiple similar error messages ?

juliancwirko commented 6 years ago

Hi, thanks. So this logic shouldn't be in the scope of the library. You can use stack: false option. It is documented. Or you can check if next error is the same as previous one and decide if you want to fire alert or not. Anyway I think that if you set the timeout for alerts it is even better UX when the same errors will appear one by one, because user will know what triggered the error in real time, but of course this is your decision.

pavangond commented 6 years ago

We want to show max 5 messages so i can't make stack to false. We don't want to set the Timeout

Is there any feature that library provides us to avoid duplicate messages ?