(props)
| 2 | import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; |
| 3 | |
| 4 | function ModalExample(props) { |
| 5 | const [modal, setModal] = useState(false); |
| 6 | const [nestedModal, setNestedModal] = useState(false); |
| 7 | const [closeAll, setCloseAll] = useState(false); |
| 8 | |
| 9 | const toggle = () => setModal(!modal); |
| 10 | const toggleNested = () => { |
| 11 | setNestedModal(!nestedModal); |
| 12 | setCloseAll(false); |
| 13 | }; |
| 14 | const toggleAll = () => { |
| 15 | setNestedModal(!nestedModal); |
| 16 | setCloseAll(true); |
| 17 | }; |
| 18 | |
| 19 | return ( |
| 20 | <div> |
| 21 | <Button color="danger" onClick={toggle}> |
| 22 | Click Me |
| 23 | </Button> |
| 24 | <Modal isOpen={modal} toggle={toggle}> |
| 25 | <ModalHeader toggle={toggle}>Modal title</ModalHeader> |
| 26 | <ModalBody> |
| 27 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do |
| 28 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad |
| 29 | minim veniam, quis nostrud exercitation ullamco laboris nisi ut |
| 30 | aliquip ex ea commodo consequat. Duis aute irure dolor in |
| 31 | reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla |
| 32 | pariatur. Excepteur sint occaecat cupidatat non proident, sunt in |
| 33 | culpa qui officia deserunt mollit anim id est laborum. |
| 34 | <br /> |
| 35 | <Button color="success" onClick={toggleNested}> |
| 36 | Show Nested Modal |
| 37 | </Button> |
| 38 | <Modal |
| 39 | isOpen={nestedModal} |
| 40 | toggle={toggleNested} |
| 41 | onClosed={closeAll ? toggle : undefined} |
| 42 | > |
| 43 | <ModalHeader>Nested Modal title</ModalHeader> |
| 44 | <ModalBody>Stuff and things</ModalBody> |
| 45 | <ModalFooter> |
| 46 | <Button color="primary" onClick={toggleNested}> |
| 47 | Done |
| 48 | </Button>{' '} |
| 49 | <Button color="secondary" onClick={toggleAll}> |
| 50 | All Done |
| 51 | </Button> |
| 52 | </ModalFooter> |
| 53 | </Modal> |
| 54 | </ModalBody> |
| 55 | <ModalFooter> |
| 56 | <Button color="primary" onClick={toggle}> |
| 57 | Do Something |
| 58 | </Button>{' '} |
| 59 | <Button color="secondary" onClick={toggle}> |
| 60 | Cancel |
| 61 | </Button> |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…