schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

Prevent duplicates #145

Closed aderahenry closed 4 years ago

aderahenry commented 4 years ago

How can duplicates be prevented? Using alert.remove(alert) does not do the job.

alexboateng commented 4 years ago

Use alert.removeAll() to remove all alerts before calling new alert

schiehll commented 4 years ago

I assume you are talking about an alert inside an useEffect hook or something like that. Try to update to the latest release and doing something like:

const { error: errorAlert } = useAlert()

useEffect(()=> {
  errorAlert("Oops, there's an error")
}, [errorAlert])

If that doesn't work, feel free to ask to reopen it.