From 3a690af6dfb70eceb3fbeb0204cc603bb7bbf9f3 Mon Sep 17 00:00:00 2001 From: Hossein Dehnokhalaji Date: Sun, 17 May 2020 16:44:10 +0100 Subject: [PATCH] Fixes #270 - Temporary fix --- src/SnackbarProvider.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/SnackbarProvider.tsx b/src/SnackbarProvider.tsx index e44f68c4..fc9afaf8 100644 --- a/src/SnackbarProvider.tsx +++ b/src/SnackbarProvider.tsx @@ -171,6 +171,10 @@ class SnackbarProvider extends Component { * Set the entered state of the snackbar with the given key. */ handleEnteredSnack: TransitionHandlerProps['onEntered'] = (node, isAppearing, key) => { + if (!key) { + throw new Error('handleEnteredSnack Cannot be called with undefined key'); + } + this.setState(({ snacks }) => ({ snacks: snacks.map(item => ( item.key === key ? { ...item, entered: true } : { ...item } @@ -223,7 +227,13 @@ class SnackbarProvider extends Component { * waiting in the queue (if any). If after this process the queue is not empty, the * oldest message is dismissed. */ - handleExitedSnack: TransitionHandlerProps['onExited'] = (event, key) => { + // @ts-ignore + handleExitedSnack: TransitionHandlerProps['onExited'] = (event, key1, key2) => { + const key = key1 || key2; + if (!key) { + throw new Error('handleExitedSnack Cannot be called with undefined key'); + } + this.setState((state) => { const newState = this.processQueue({ ...state,