We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { useNavigate } from "react-router-dom";
const navigate = useNavigate(); const handleCreate = useCallback( (e: any) => { createName(props.name, props.description) .then((response) => { navigate("/"); enqueueSnackbar("Successfully added a new name", {variant: "success"}); }) .catch((error) => { enqueueSnackbar(error.message.toString(), {variant: "error"}); }); }, [props.description, props.name, navigate] );
I see the snackbar when I get the error, but when I am successful I do not see the snackbar
The text was updated successfully, but these errors were encountered:
@randerso21 I'd need a minimal reproduction example to be able to help
Sorry, something went wrong.
Does this work? File name is Hist.tsx
`import React from "react"; import { Helmet } from "react-helmet"; import { useNavigate } from "react-router-dom"; import Button from '@mui/material/Button'; import { SnackbarProvider, useSnackbar } from 'notistack';
function Hist() { const navigate = useNavigate(); const { enqueueSnackbar } = useSnackbar();
const handleClick = () => { navigate("/"); enqueueSnackbar('I love snacks.'); };
const handleClickVariant = (message: string, variant: any) => () => { enqueueSnackbar(message, { variant }); };
return (
<React.Fragment> <Button onClick={handleClick}>Show snackbar</Button> <Button onClick={handleClickVariant("This is a SUCCESS", 'success')}>Show success snackbar</Button> <Button onClick={handleClickVariant("This is an ERROR", 'error')}>Show error snackbar</Button> </React.Fragment> </div>
); } function Hist2() { return ( ); }
export default Hist2; `
No branches or pull requests
import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
const handleCreate = useCallback(
(e: any) => {
createName(props.name, props.description)
.then((response) => {
navigate("/");
enqueueSnackbar("Successfully added a new name", {variant: "success"});
})
.catch((error) => {
enqueueSnackbar(error.message.toString(), {variant: "error"});
});
},
[props.description, props.name, navigate]
);
I see the snackbar when I get the error, but when I am successful I do not see the snackbar
The text was updated successfully, but these errors were encountered: