Это код, который я реализовал
<DayPickerRangeController
startDate={startDate}
startDateId="startDateId"
endDate={endDate}
endDateId="endDateId"
onDatesChange={(date) => console.log(date)}
focusedInput={focus}
onFocusChange={(focus) => console.log(focus)}
/>
Но onDatesChange возвращает null
{startDate: null, endDate: null}
вот мои хуки
const [dateRange, setDateRange] = useState({
startDate: null,
endDate: null,
});
const [focus, setFocus] = useState(null);
const { startDate, endDate } = dateRange;
Есть идеи почему?
Это мой импорт
import 'react-dates/initialize';
import { DayPickerRangeController } from 'react-dates';
вот полный код
import 'react-dates/initialize';
import { DayPickerRangeController } from 'react-dates';
const DatePicker = ({ name, items, handler }) => {
const [dateRange, setDateRange] = useState({
startDate: null,
endDate: null,
});
const [focus, setFocus] = useState(null);
const { startDate, endDate } = dateRange;
return (
<DayPickerRangeController
startDate={startDate}
startDateId="startDateId"
endDate={endDate}
endDateId="endDateId"
onDatesChange={(date) => console.log(date)}
focusedInput={focus}
onFocusChange={(focus) => console.log(focus)}
/>
)
}