File size: 555 Bytes
3206347 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import { useSnackbar } from 'notistack';
export default function useEnqueueSnackbar() {
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
return function wrappedEnqueueSnackbar(message, options) {
const key = enqueueSnackbar(message, {
...(options || {}),
SnackbarProps: {
onClick: () => closeSnackbar(key),
...{
'data-test': 'snackbar',
'data-snackbar-variant': `${options.variant}` || 'default',
},
...(options.SnackbarProps || {}),
},
});
return key;
};
}
|