From 934330272f070a471b7826ba4fc61a77bfa87d44 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 22 Jul 2022 15:29:11 -0500 Subject: [PATCH] alerts/sagas: avoid reentrancy for dismiss This fixes react complaining about calling setState from an invalid context. --- src/alerts/sagas.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/alerts/sagas.ts b/src/alerts/sagas.ts index f12a29c9..421b8c11 100644 --- a/src/alerts/sagas.ts +++ b/src/alerts/sagas.ts @@ -35,7 +35,9 @@ function* handleShowAlert(action: ReturnType): Generator try { const alertAction = yield* take(chan); // the dismiss actions will have called this already, but other actions don't - toaster.dismiss(key); + if (alertAction !== 'dismiss') { + toaster.dismiss(key); + } yield* put(alertsDidShowAlert(action.domain, action.specific, alertAction)); } finally {