I am using DatePicker from antd.
<LocaleProvider locale={enUS}>
<DatePicker
format="MM/D/YYYY HH:mm"
defaultValue={this.getStartValue()}
showTime={{format: 'HH:mm'}}
placeholder="Start"
allowClear={false}
onOk={this.onStartTimeChange}
/>
</LocaleProvider>
<LocaleProvider locale={enUS}>
<DatePicker
format="MM/DD/YYYY HH:mm"
defaultValue={this.getEndValue()}
showTime={{format: 'HH:mm'}}
placeholder="End"
allowClear={false}
onOk={this.onEndTimeChange}
/>
</LocaleProvider>
I am showing value from state and onOK am changing state with the new value. Now issue am facing is when user manually edit the time.
Is there a way to
Is onChange only way to do it as onChnage will change my state multiple time on almost each user click. If onChange is recommended way then can we avoid ok button itself?
After searching online and trying.
We can use onChange and this will handle all things.
<DatePicker
format='MM/DD/YYYY HH:mm'
defaultValue={this.getFromValue()}
showTime={{format: 'HH:mm'}}
placeholder="Start"
allowClear={false}
showToday={false}
disabledDate={this.disabledFromDate}
onChange={this.onStartTimeChange}
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.