Skip to content

Commit

Permalink
fix(Modal): run close based on prop, not state
Browse files Browse the repository at this point in the history
Due to setState's async nature, when the modal is opened and closed before setState has finished the modal does not properly cleanup after itself.
Since the init which add the body class is based on props, not state; this change makes the close that cleans up the body class be based on props and not state as well.

fixes #1626
  • Loading branch information
TheSharpieOne committed Dec 10, 2019
1 parent c088c58 commit 310b061
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Modal.js
Expand Up @@ -147,7 +147,7 @@ class Modal extends React.Component {

if (this._element) {
this.destroy();
if (this.state.isOpen) {
if (this.props.isOpen) {
this.close();
}
}
Expand Down

0 comments on commit 310b061

Please sign in to comment.