MCPcopy Create free account
hub / github.com/reactstrap/reactstrap / ModalExample

Function ModalExample

stories/examples/Modal/DestructuringExample.js:14–63  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

12} from 'reactstrap';
13
14function ModalExample(props) {
15 const [modal, setModal] = useState(false);
16 const [unmountOnClose, setUnmountOnClose] = useState(true);
17
18 const toggle = () => setModal(!modal);
19 const changeUnmountOnClose = (e) => {
20 let { value } = e.target;
21 setUnmountOnClose(JSON.parse(value));
22 };
23
24 return (
25 <div>
26 <Form onSubmit={(e) => e.preventDefault()}>
27 <FormGroup>
28 <Label for="unmountOnClose">UnmountOnClose value</Label>{' '}
29 <Input
30 type="select"
31 name="unmountOnClose"
32 id="unmountOnClose"
33 onChange={changeUnmountOnClose}
34 >
35 <option value="true">true</option>
36 <option value="false">false</option>
37 </Input>
38 </FormGroup>{' '}
39 <Button color="danger" onClick={toggle}>
40 Click Me
41 </Button>
42 </Form>
43 <Modal isOpen={modal} toggle={toggle} unmountOnClose={unmountOnClose}>
44 <ModalHeader toggle={toggle}>Modal title</ModalHeader>
45 <ModalBody>
46 <Input
47 type="textarea"
48 placeholder="Write something (data should remain in modal if unmountOnClose is set to false)"
49 rows={5}
50 />
51 </ModalBody>
52 <ModalFooter>
53 <Button color="primary" onClick={toggle}>
54 Do Something
55 </Button>{' '}
56 <Button color="secondary" onClick={toggle}>
57 Cancel
58 </Button>
59 </ModalFooter>
60 </Modal>
61 </div>
62 );
63}
64
65export default ModalExample;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…