(props)
| 13 | import PropTypes from 'prop-types'; |
| 14 | |
| 15 | function 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">“static“</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> |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…