import React from 'react' ; import CloseIcon from '@material-ui/icons/Close' ; import { SnackbarProvider } from 'notistack' ; import BaseIconButton from '@src/modules/shared/BaseIconButton' ; const notistackRef = React . createRef < SnackbarProvider > ( ) ; export const notifyErrorByRef = ( message ) => { notistackRef . current ?. enqueueSnackbar ( message , { variant : 'error' } ) ; } ; const renderSnackbarAction = ( key ) => ( < BaseIconButton color = "inherit" onClick = { ( ) => notistackRef . current ?. closeSnackbar ( key ) } > < CloseIcon fontSize = "inherit" / > < /BaseIconButton>); type BaseSnackbarProviderProps = React . PropsWithChildren < { } > ; function BaseSnackbarProvider ( { children } ) { return ( < SnackbarProvider ref = { notistackRef } action = { renderSnackbarAction } > { children } < /SnackbarProvider>); } export default BaseSnackbarProvider ;