Date does not change (from Selected date)
I'm using a react datepicker (https://github.com/Hacker0x01/react-datepicker/) When i change the date the value doesn't change to the date that i clicked.
"react": "^17.0.1", "react-redux": "^7.1.3", "react-router-dom": "^5.1.2", "react-datepicker": "^4.3.0"
My Code: ------------------------- ------------------------- -------------------------
<DatePicker
name="dob"
className="form-control"
showMonthDropdown
showYearDropdown
scrollableYearDropdown
dropdownMode="select"
showPopperArrow={false}
todayButton="Today"
onChange={onChange(apiData.dob)}
selected={moment(apiData.dob).toDate()}
dateFormat="dd/MM/yyyy"
value={moment(apiData.dob).toDate()}
defaultValue={moment(apiData.dob).toDate()}>
const onChange = (i) => (e) => {
if (i === apiData.dob) {
setupInputValue((preValue) => {
const dobFormat = moment(e).format('YYYY-MM-DD')
return {
...preValue,
dob: dobFormat
};
});
} else {
const { name, value } = e.target;
setupInputValue((preValue) => {
return {
...preValue,
[name]: value
};
});
}};
Hope someone has the answer for me!
Facing the same issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.