diff --git a/src/SnackbarContext.ts b/src/SnackbarContext.ts index cf8f2f8..c2640ac 100644 --- a/src/SnackbarContext.ts +++ b/src/SnackbarContext.ts @@ -8,4 +8,5 @@ const noOp = () => { export default React.createContext({ enqueueSnackbar: noOp, closeSnackbar: noOp, + snackCount: 0 }); diff --git a/src/SnackbarProvider/SnackbarProvider.tsx b/src/SnackbarProvider/SnackbarProvider.tsx index c404716..e2c46b0 100644 --- a/src/SnackbarProvider/SnackbarProvider.tsx +++ b/src/SnackbarProvider/SnackbarProvider.tsx @@ -50,6 +50,7 @@ class SnackbarProvider extends Component { contextValue: { enqueueSnackbar: this.enqueueSnackbar.bind(this), closeSnackbar: this.closeSnackbar.bind(this), + snackCount: this.state.snacks.length }, }; } diff --git a/src/types.ts b/src/types.ts index 54dbe7d..f770410 100644 --- a/src/types.ts +++ b/src/types.ts @@ -406,6 +406,7 @@ interface EnqueueSnackbar { export interface ProviderContext { enqueueSnackbar: EnqueueSnackbar; closeSnackbar: (key?: SnackbarKey) => void; + snackCount: number } export declare class SnackbarProvider extends React.Component {