fix: Ensure safe removal of event listeners in EditServerModal and DeleteServerModal to prevent potential memory leaks
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 13m32s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 13m32s
This commit is contained in:
@@ -533,7 +533,9 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
|
||||
const handler = () => onClose && onClose();
|
||||
modalRef.current.addEventListener('hide.bs.modal', handler);
|
||||
return () => {
|
||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||
if (modalRef.current) {
|
||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
}, [show, onClose]);
|
||||
@@ -600,7 +602,9 @@ function DeleteServerModal({ show, server, onDelete, onClose }) {
|
||||
const handler = () => onClose && onClose();
|
||||
modalRef.current.addEventListener('hide.bs.modal', handler);
|
||||
return () => {
|
||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||
if (modalRef.current) {
|
||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
}, [show, onClose]);
|
||||
|
||||
Reference in New Issue
Block a user