DatePicker

DatePicker is a flexible time and date selection component that supports multiple modes.

Code demo

During the selection process, DatePicker will return the currently selected value as the parameter of the onDateChange callback.
(1)Controlled date picker, for the explanation of controlled components, please refer to here:Forms. The value of DatePicker depends on the date passed in, so we need to manually re-pass the returned value to the component, thus completing a selection.
(2)Uncontrolled date picker, for the explanation of uncontrolled components, please refer to here:Uncontrolled Components. The value of DatePicker depends on the internal state.

Controlled date picker

import { DatePicker } from 'tuya-panel-kit'
const [selectDate, setDate] = React.useState(new Date());
<DatePicker
style={{ marginTop: 30 }}
date={selectDate}
onDateChange={selectDate => setDate(selectDate)}
/>

Uncontrolled date picker

import { DatePicker } from 'tuya-panel-kit'
<DatePicker
style={{ marginTop: 50 }}
defaultDate={new Date()}
onDateChange={date => console.log(date)}
/>

API

extends PickerViewProps

tuya01:01