adjusting the ref type for the snackbar provider
This commit is contained in:
parent
2fc25431bd
commit
77f0f778a3
1 changed files with 5 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import { Button, Theme } from "@mui/material";
|
import { Button, Theme } from "@mui/material";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import {
|
import {
|
||||||
ProviderContext as NotistackProviderContext,
|
|
||||||
SnackbarAction,
|
SnackbarAction,
|
||||||
SnackbarProvider as NotistackSnackbarProvider,
|
SnackbarProvider as NotistackSnackbarProvider,
|
||||||
useSnackbar as useNotistackSnackbar
|
useSnackbar as useNotistackSnackbar
|
||||||
|
|
@ -95,15 +94,17 @@ function SnackbarHelper(props: PropsWithChildren<Props>) {
|
||||||
export default function SnackbarProvider(props: PropsWithChildren<Props>) {
|
export default function SnackbarProvider(props: PropsWithChildren<Props>) {
|
||||||
const { children } = props;
|
const { children } = props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const notistackRef = React.createRef<NotistackProviderContext>();
|
const providerRef = React.createRef<NotistackSnackbarProvider>();
|
||||||
|
|
||||||
const onClickDismiss = (key: React.ReactText) => () => {
|
const onClickDismiss = (key: React.ReactText) => () => {
|
||||||
if (notistackRef && notistackRef.current) notistackRef.current.closeSnackbar(key);
|
if (providerRef && providerRef.current) {
|
||||||
|
providerRef.current.closeSnackbar(key);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NotistackSnackbarProvider
|
<NotistackSnackbarProvider
|
||||||
// ref={notistackRef}
|
ref={providerRef}
|
||||||
maxSnack={1}
|
maxSnack={1}
|
||||||
anchorOrigin={{
|
anchorOrigin={{
|
||||||
vertical: "bottom",
|
vertical: "bottom",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue