fix: add null checks for document and firebase messaging to prevent SSR errors

Added defensive programming by adding null checks for document object before accessing its properties and methods across multiple components (MultiSelect, ConfirmationModal, Dropdown, Modal). Also implemented lazy initialization for Firebase messaging to prevent SSR-related errors and ensure messaging is only initialized on the client side. These changes improve server-side rendering compatibility and prevent potential runtime errors.
This commit is contained in:
AmirReza Jamali
2025-11-15 12:22:30 +03:30
parent 5e60a292f5
commit 1d1027fab4
6 changed files with 50 additions and 17 deletions
+2 -1
View File
@@ -130,8 +130,9 @@ function MultiSelect<T extends FieldValues>({
return;
setShow(false);
};
document?.addEventListener("click", clickHandler);
return () => document.removeEventListener("click", clickHandler);
return () => document?.removeEventListener("click", clickHandler);
}, [show]);
return (