Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

fix(contacts): own the progress toast lifecycle in a single effect

Jerome1676f6c47d4b
diff --git a/src/components/atomic-crm/contacts/ContactImportProvider.tsx b/src/components/atomic-crm/contacts/ContactImportProvider.tsx
index 8c3fc3b2..90b37392 100644
--- a/src/components/atomic-crm/contacts/ContactImportProvider.tsx
+++ b/src/components/atomic-crm/contacts/ContactImportProvider.tsx
@@ -220,10 +220,15 @@ const ContactImportProgressToast = ({
importer.state === "running" ? importer.remainingTime : null;
useEffect(() => {
- if (!isImporting) {
+ if (!isImporting) return;
+
+ return () => {
toast.dismiss(TOAST_ID);
- return;
- }
+ };
+ }, [isImporting]);
+
+ useEffect(() => {
+ if (!isImporting) return;
toast.custom(
() => (
@@ -278,13 +283,6 @@ const ContactImportProgressToast = ({
onStop,
]);
- useEffect(
- () => () => {
- toast.dismiss(TOAST_ID);
- },
- [],
- );
-
return null;
};