Answers for "Notistack"

0

Notistack

import { useSnackbar } from 'notistack';

const MyButton = () => {
    const { enqueueSnackbar, closeSnackbar } = useSnackbar();

    const handleClick = () => {
        enqueueSnackbar('I love hooks');
    };

    return (
        <Button onClick={handleClick}>Show snackbar</Button>
    );
}
Posted by: Guest on October-03-2020
0

notistack

// on connection loss
const key = props.enqueueSnackbar('No connection!', { 
    variant: 'error',
    persist: true,
});

// when we're back online
props.closeSnackbar(key);
Posted by: Guest on February-09-2021

Browse Popular Code Answers by Language