How to stop event from bubbling when exiting react-bootstrap modal?

Viewed 709

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.

1 Answers

The workaround was to use a div element around the Modal to control the event.

<div 
onClick ={(e) => e.preventPropagation()}
>
<Modal>
<Modal/>
</div>
Related