Open simon-abbott opened 1 year ago
Possible duplicate of #557. Didn't search well enough before hitting submit I guess.
@simon-abbott Each SnackbarProvider
enforces its own maxSnack
limit. So depending on your requirements, you might be able to simply use 2 SnackbarProviders, one* dedicated to "browser offline listener", the other dedicated to other types of notifications.
If you do this, make sure you show snackbars by using enqueueSnackbar
from useSnackbar
.
// don't do
import { enqueueSnackbar } from 'notistack'
// instead do
import { useSnackbar } from 'notistack'
const MyComponent = () => {
const { enqueueSnackbar } = useSnackbar()
// ...
}
P.S: This workaround works better if your "browser offline listener" snackbars are positioned differently from other types of snackbars. For example, use bottom-center as anchorOrigin
for these notifications, and stick to bottom-left for other types of notifications.
Either way I understand non of these are ideal, but thought I'd share :)
This project is awesome, and has saved me a ton of time setting up notifications in a webapp I'm working on, but there's one small quirk I noticed. I set up an "is the browser offline" listener that displays a persistent alert if the answer is yes. It works great, but it eats up one of the
maxSnack
slots even though I'm setting it to persistent and displaying it with a different anchor origin. It would be great if there was a way to tellenqueueSnackbar
"hey, don't count this one towards the limit". I don't think it's likely to be an actual problem in practice since we're usually only going to have one normal alert at a time anyway, but it still seems like a missing feature from this otherwise amazingly customizable package.