Notistack: How to use notistack with a React functional component?

Created on 2 Dec 2019  路  1Comment  路  Source: iamhosseindhv/notistack

The example shows how to use notistack in a React class component. How would notistack be used in a React functional component?

Most helpful comment

Hi, https://iamhosseindhv.com/notistack How to use, Step 2:

import { useSnackbar } from 'notistack';

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

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

    return (
        <Button onClick={handleClick}>Show snackbar</Button>
    );
}

>All comments

Hi, https://iamhosseindhv.com/notistack How to use, Step 2:

import { useSnackbar } from 'notistack';

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

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

    return (
        <Button onClick={handleClick}>Show snackbar</Button>
    );
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nebojsanb picture nebojsanb  路  3Comments

RastislavMirek picture RastislavMirek  路  8Comments

khanhdinovative picture khanhdinovative  路  3Comments

Brettm12345 picture Brettm12345  路  6Comments

VincentLanglet picture VincentLanglet  路  5Comments