I
I
Ilya Kuminov2021-03-04 22:01:20
Bootstrap
Ilya Kuminov, 2021-03-04 22:01:20

Why is Static backdrop from React Bootstrap not working?

The button itself appears on the site, but for some reason it is not active.

here is the code

60412e1fa7ee6937692033.png

import React, {  useState } from "react";
import {Button} from 'react-bootstrap'
import Modal from 'react-modal';



const Hack = () =>  {
    const [show, setShow] = useState(false);

    const handleClose = () => setShow(false);
    const handleShow = () => setShow(true);

return (
    <>
    <Button variant="primary" onClick={handleShow}>
        ЖМЯК
    </Button>

    <Modal
        show={show}
        onHide={handleClose}
        backdrop="static"
        keyboard={false}
    >
        <Modal.Header closeButton>
        <Modal.Title>Modal title</Modal.Title>
        </Modal.Header>
        <Modal.Body>
        I will not close if you click outside me. Don't even try to press
        escape key.
        </Modal.Body>
        <Modal.Footer>
        <Button variant="secondary" onClick={handleClose}>
            Close
        </Button>
        <Button variant="primary">Understood</Button>
        </Modal.Footer>
    </Modal>
    </>
);
}

export default Hack;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Kuminov, 2021-03-05
@Minister21

not a correct Modal import, it should beimport Modal from 'react-bootstrap/Modal'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question