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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user