Reputation: 491
Problem
After closing the modal the datepicker of antd not reset If user select the date 2029/Feb/02 and close the modal after reopen the modal in datepicker selected year is 2029
What I want
After reopen the modal the today date would be selected
What I tried
According to doc Antd if defaultPickerValue is set then it should show the current date on modal reopen, but it's not working
defaultPickerValue={moment()}
Code
Upvotes: 0
Views: 1970
Reputation: 151
You need to set the initial state value to undefined
instead of ""
. defaultValue
will only set the value if the value
prop is actually undefined
.
EDIT: You also need to add destroyOnClose
on the Modal
. defaultValue
is only set once when the component is mounted and since closing the modal is not actually unmounting the component, it will retain its state value.
Upvotes: 1