By default, a snackbar is removed after 3 seconds. A custom timeout can be specified in one of two ways:
timeout
prop on the SnackbarProvider
for all snackbarstimeout
property on the object passed to createSnackbar
for a specific snackbarimport React from 'react';
import { SnackbarProvider, wrapComponent } from 'react-snackbar-alert';
export default function CustomTimeoutExample() {
return (
<SnackbarProvider timeout={5000}>
<Container />
</SnackbarProvider>
);
}
const Container = wrapComponent(function({ createSnackbar }) {
function showSnackbar() {
createSnackbar({
message: 'Hello Snackbar!'
});
}
return (
<div>
<button onClick={showSnackbar}>Show Snackbar</button>
</div>
);
});