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

Function Example

stories/examples/Modal/BackdropExample.js:15–93  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

13import PropTypes from 'prop-types';
14
15function Example(props) {
16 const { className } = props;
17 const [modal, setModal] = useState(false);
18 const [backdrop, setBackdrop] = useState(true);
19 const [keyboard, setKeyboard] = useState(true);
20
21 const toggle = () => setModal(!modal);
22
23 const changeBackdrop = (e) => {
24 let { value } = e.target;
25 if (value !== 'static') {
26 value = JSON.parse(value);
27 }
28 setBackdrop(value);
29 };
30
31 const changeKeyboard = (e) => {
32 setKeyboard(e.currentTarget.checked);
33 };
34
35 return (
36 <div>
37 <Form onSubmit={(e) => e.preventDefault()}>
38 <FormGroup>
39 <Label for="backdrop">Backdrop value</Label>{' '}
40 <Input
41 type="select"
42 name="backdrop"
43 id="backdrop"
44 onChange={changeBackdrop}
45 >
46 <option value="true">true</option>
47 <option value="false">false</option>
48 <option value="static">&ldquo;static&ldquo;</option>
49 </Input>
50 </FormGroup>
51 <FormGroup className="mx-2" check>
52 <Label check>
53 <Input
54 type="checkbox"
55 checked={keyboard}
56 onChange={changeKeyboard}
57 />{' '}
58 Keyboard
59 </Label>
60 </FormGroup>{' '}
61 <Button color="danger" onClick={toggle}>
62 Click Me
63 </Button>
64 </Form>
65 <Modal
66 isOpen={modal}
67 toggle={toggle}
68 className={className}
69 backdrop={backdrop}
70 keyboard={keyboard}
71 >
72 <ModalHeader toggle={toggle}>Modal title</ModalHeader>

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…