Skip to content

An opinionated toast component for React.

Fix useEffect error (#47)

Emil Kowalskicba1ceab5a97
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]);
+ });
});
});
}, []);