Skip to content

Commit c4e0e39

Browse files
committed
fix(modals): check if modal is mounted before updating style
1 parent 8bdd5b4 commit c4e0e39

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/dialog/Modal.jsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ Modal.propTypes = {
115115
};
116116

117117
function hideModal(modalRef) {
118-
modalRef.current.style.display = 'none';
119-
modalRef.current.classList.remove('show');
118+
if (modalRef.current) {
119+
modalRef.current.style.display = 'none';
120+
modalRef.current.classList.remove('show');
121+
}
120122

121123
hideModalBackdrop();
122124
enableBodyScroll();
123125

124-
if (modalRef.current.style.zIndex) {
126+
if (modalRef.current && modalRef.current.style.zIndex) {
125127
modalRef.current.style.zIndex = null;
126128
}
127129
}
@@ -133,6 +135,10 @@ function enableBodyScroll() {
133135
}
134136

135137
function showModal(modalRef) {
138+
if (!modalRef.current) {
139+
return;
140+
}
141+
136142
disableBodyScroll();
137143
showModalBackdrop();
138144

0 commit comments

Comments
 (0)