mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 16:19:15 +08:00
e7aa014c31
* docs: init * chore: all types * docs: faq * chore: fix lint
34 lines
878 B
TypeScript
34 lines
878 B
TypeScript
import React from 'react';
|
|
import { DatePicker, Space } from 'antd';
|
|
import type { DatePickerProps, GetProps } from 'antd';
|
|
|
|
type RangePickerProps = GetProps<typeof DatePicker.RangePicker>;
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
const onChange = (
|
|
value: DatePickerProps['value'] | RangePickerProps['value'],
|
|
dateString: [string, string] | string,
|
|
) => {
|
|
console.log('Selected Time: ', value);
|
|
console.log('Formatted Selected Time: ', dateString);
|
|
};
|
|
|
|
const onOk = (value: DatePickerProps['value'] | RangePickerProps['value']) => {
|
|
console.log('onOk: ', value);
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Space direction="vertical" size={12}>
|
|
<DatePicker showTime onChange={onChange} onOk={onOk} />
|
|
<RangePicker
|
|
showTime={{ format: 'HH:mm' }}
|
|
format="YYYY-MM-DD HH:mm"
|
|
onChange={onChange}
|
|
onOk={onOk}
|
|
/>
|
|
</Space>
|
|
);
|
|
|
|
export default App;
|