A snackbar can be sticky, which means that it is not automatically removed. This can be done in one of two ways:
sticky
prop on the SnackbarProvider
to make all snackbars stickysticky
property on the object passed to createSnackbar
to make a specific snackbar stickyIt is recommended that sticky snackbars are also user-dismissable, otherwise the snackbar can never be removed.
import React from 'react';
import { SnackbarProvider, wrapComponent } from 'react-snackbar-alert';
export default function StickyExample() {
return (
<SnackbarProvider dismissable={true} sticky={true}>
<Container />
</SnackbarProvider>
);
}
const Container = wrapComponent(function({ createSnackbar }) {
function showSnackbar() {
createSnackbar({
message: 'Hello Snackbar!'
});
}
return (
<div>
<button onClick={showSnackbar}>Show Snackbar</button>
</div>
);
});