It is not clear for what reason an error is received when activating the date picker. I would be happy to some help.
The error is:
"value.getTime is not a function. (In 'value.getTime ()', 'value.getTime' is undefined"
MyDatePicker function
let date1 = useSelector(state => state.DatePickerReducer.date1);
DatePickerReducer
const today = new Date();
const initializeState = {
date1: new Date(new Date().getFullYear(), 0, 1, 10),
date2: today.addMonths(1)
};
export default function DatePickerReducer(state = initializeState, action) {
switch (action.type) {
case SET_DATE_1:
return {
...state,
date1: action.payload ? action.payload : state.date1,
};
I think your date object is getting serialized into string. Try wrapping the date1 variable in a date object in your MyDatePicker function.
let dateString= useSelector(state => state.DatePickerReducer.date1);
let date1 =new Date(dateString);
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.