javascript - Ant Design: defaultValue of <DatePicker> component is not working as expected - Stack Overflow

I am creating a detail page where I want to display an editable deadline and for that, I am using <D

I am creating a detail page where I want to display an editable deadline and for that, I am using <DatePicker> ponent of Ant Design. The problem is when I set defaultValue={moment(deadline)} it's not showing the date deadline variable is holding but instead, it is showing the current date.

<DatePicker
    showTime
    format="YYYY-MM-DD HH:mm:ss"
    placeholder="Set Deadline"
    defaultValue={moment(deadline)} //moment(deadline) returns valid moment date objcect
    onOk={(value, dateString) => {
        newDeadline = value._d;
        updateDeadline(newDeadline);
    }}
/>

I don't know where I am doing wrong please help me to find it out...

UPDATE

When I console the value of deadline, typeof deadline, moment(deadline).toString() all are returning data as expected.

When I use value={moment(deadline)} instead of defaultValue={moment(deadline)}, It's also working fine. One interesting thing, when I pass date string instead of deadline variable to defaultValue, It's working smoothly.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745672011a4639460.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信