react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Date does not change (from Selected date)

Open jaintarun268 opened this issue 5 years ago • 2 comments

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!

jaintarun268 avatar Oct 28 '21 07:10 jaintarun268

Facing the same issue

Shahzaibmalik55 avatar Feb 07 '22 08:02 Shahzaibmalik55

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.

stale[bot] avatar Aug 13 '22 06:08 stale[bot]