This is DayPickerRangeController
component from react-dates
:
<DayPickerRangeController
startDate={dates.startDate}
endDate={dates.endDate}
onDatesChange={onDatesChange}
focusedInput={focusedInput}
onFocusChange={focusedInput => setFocusedInput(focusedInput)}
numberOfMonths={2}
/>
I am using a functional component and the default state is:
const [dates, setDates] = useState({ startDate: null, endDate: null });
const [focusedInput, setFocusedInput] = useState(null);
This is changeDates function:
const onDatesChange = (dates) => {
//setDates({ startDate, endDate });
console.log(dates);
}
, but on dates change, the result is this: {startDate: null, endDate: null}
I can change the default date to invaling string like so:
const [dates, setDates] = useState({ startDate: 'jkhjkhjk', endDate: null });
and the result on bind the change event {startDate: "jkhjkhjk", endDate: null}
with the warning for invalid value for a date