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();
|
const handler = () => onClose && onClose();
|
||||||
modalRef.current.addEventListener('hide.bs.modal', handler);
|
modalRef.current.addEventListener('hide.bs.modal', handler);
|
||||||
return () => {
|
return () => {
|
||||||
|
if (modalRef.current) {
|
||||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [show, onClose]);
|
}, [show, onClose]);
|
||||||
@@ -600,7 +602,9 @@ function DeleteServerModal({ show, server, onDelete, onClose }) {
|
|||||||
const handler = () => onClose && onClose();
|
const handler = () => onClose && onClose();
|
||||||
modalRef.current.addEventListener('hide.bs.modal', handler);
|
modalRef.current.addEventListener('hide.bs.modal', handler);
|
||||||
return () => {
|
return () => {
|
||||||
|
if (modalRef.current) {
|
||||||
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
modalRef.current.removeEventListener('hide.bs.modal', handler);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [show, onClose]);
|
}, [show, onClose]);
|
||||||
|
|||||||
Reference in New Issue
Block a user