I'm using react modal, and the modal will not close upon clicking the overlay. I provide props to both isOpen and onRequestClose, but the modal remains open.
closeModal= () => {
this.setState({ modalIsOpen: false });
};
<Modal
isOpen={this.state.modalIsOpen}
onRequestClose={this.closeModal}
shouldCloseOnOverlayClick={true}
>
<div>This is my Modal</div>
<Button onClick={this.closeModal}>Close Modal<Button>
</Modal>
I know this has been an issue in the past. Is there anything else I can try? Thank you in advance.
From docs you can see this:
Your code looks fine, maybe the issue is with the version you're using, might have an issue with shouldCloseOnOverlayClick prop. Try without adding the prop, and also check your react-modal version.
If you have easy mode for using modal with react, for me is the best away is insert from template index.html in my case it is file in public folder CDN links for bootstrap and jQuery and than make folder for Modal there make two file: index.js and modal.js.
In first is code `import React from 'react'; import MOdal from'./pomocna_modal';
class Modal_gl extends React.Component{
}
export default Modal_gl;
In second code is
* Created by trika on 19-Jan-18. */ import React from 'react';
class Modal extends React.Component{
}; export default Modal;
for calling modal You must use bootstrap code between html tags from where you wish calling Modal like this data-toggle="modal" data-target="#myModal"
This issue is fixed in versiion 2.2.2.