Skip to content

Commit 9241209

Browse files
committed
Revert ModalUnstyled change
Was first suspicion but breaks React 17
1 parent 843b682 commit 9241209

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/material-ui-unstyled/src/ModalUnstyled/ModalUnstyled.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,18 @@ const ModalUnstyled = React.forwardRef(function ModalUnstyled(props, ref) {
137137
manager.remove(getModal());
138138
}, [manager]);
139139

140+
React.useEffect(() => {
141+
return () => {
142+
handleClose();
143+
};
144+
}, [handleClose]);
145+
140146
React.useEffect(() => {
141147
if (open) {
142148
handleOpen();
143-
144-
return () => {
145-
if (!hasTransition || !closeAfterTransition) {
146-
handleClose();
147-
}
148-
};
149+
} else if (!hasTransition || !closeAfterTransition) {
150+
handleClose();
149151
}
150-
return undefined;
151152
}, [open, handleClose, hasTransition, closeAfterTransition, handleOpen]);
152153

153154
const styleProps = {

0 commit comments

Comments
 (0)