Reputation: 121
Say I want to stop the event from propagating upon exit from the modal, for example when clicking on the background or the exit button which will close the modal. But then it'll redirect me to the (parent)? onClick event upon exiting.
<Modal onHide={(e) => {
e.stopPropagation();
setShow(false);
...
}}>
<Modal/>
The above does not work. I also tried onExit
which also doesn't work.
Upvotes: 2
Views: 1695
Reputation: 121
The workaround was to use a div element around the Modal to control the event.
<div
onClick ={(e) => e.stopPropagation()}
>
<Modal>
<Modal/>
</div>
Upvotes: 8