Search code examples
reactjsreact-bootstrap

If conditional stop closing of modal on outside click in React


I have modal. I use this modal why upload video. So when ı upload video, I waiting for it to upload. While continuing uploading, I want to stop closing of modal on outside click, but while not uploading then can be close.

<Modal
    show={show}
    onHide={handleClose}
    backdrop="static"
    keyboard={false}>
</Modal>

Solution

  • need more details about your code but generally you have to check uploading status on handleClose like so

    handleClose = () => {
        if(uploading) {
            return false 
        } else {
            setShow(false)
        }
    
    }