node/@patternfly/react-core/src/components/DatePicker/examples/DatePickerControlledCalendar.tsx
raw| 1 | import { Fragment, useRef } from 'react'; |
| 2 | import { Button, DatePicker } from '@patternfly/react-core'; |
| 3 | |
| 4 | export const DatePickerControlledCalendar: React.FunctionComponent = () => { |
| 5 | const dateRef = useRef(null); |
| 6 | const onClick = () => { |
| 7 | if (dateRef.current) { |
| 8 | dateRef.current.toggleCalendar(); |
| 9 | } |
| 10 | }; |
| 11 | return ( |
| 12 | <Fragment> |
| 13 | <DatePicker ref={dateRef} /> |
| 14 | <br /> |
| 15 | <br /> |
| 16 | <Button onClick={onClick}>Toggle calendar</Button> |
| 17 | </Fragment> |
| 18 | ); |
| 19 | }; |