From cba1ceab5a97ef0681cac51dd1e062795ed2005a Mon Sep 17 00:00:00 2001 From: Emil Kowalski <36730035+emilkowalski@users.noreply.github.com> Date: Mon, 20 Mar 2023 15:43:58 +0100 Subject: [PATCH] Fix useEffect error (#47) --- src/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 4dbf881..9333d9b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -408,9 +408,11 @@ const Toaster = (props: ToasterProps) => { return; } - // Don't batch update toasts to prevent wrong calculations - ReactDOM.flushSync(() => { - setToasts((toasts) => [toast, ...toasts]); + // Prevent batching, temp solution. + setTimeout(() => { + ReactDOM.flushSync(() => { + setToasts((toasts) => [toast, ...toasts]); + }); }); }); }, []);