I did something similar with the Modal component. But I also had to include an event listener when the user clicks outside of the modal to close it:
useEffect(()=>{constmyModal=modalRef.currentasunknownasElementletbsModal=Modal.getInstance(myModal)if(!bsModal){bsModal=newModal(myModal)bsModal.hide()setModal(false)// When the user clicks on underlay to close the modalmyModal.addEventListener("hide.bs.modal",()=>{setModal(false)})}else{modal?bsModal.show():bsModal.hide()}},[modal])
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I did something similar with the Modal component. But I also had to include an event listener when the user clicks outside of the modal to close it: