onDatesChange returns null
See original GitHub issueThis is code that I implemented
<DayPickerRangeController
startDate={startDate}
startDateId="startDateId"
endDate={endDate}
endDateId="endDateId"
onDatesChange={(date) => console.log(date)}
focusedInput={focus}
onFocusChange={(focus) => console.log(focus)}
/>
But onDatesChange returns null
{startDate: null, endDate: null}
here are my hooks
const [dateRange, setDateRange] = useState({
startDate: null,
endDate: null,
});
const [focus, setFocus] = useState(null);
const { startDate, endDate } = dateRange;
Any ideas why?
These are my imports
import 'react-dates/initialize';
import { DayPickerRangeController } from 'react-dates';
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
onDatesChange returns null · Issue #1953 · react-dates/react ...
This is code that I implemented console.log(date)} focusedInput={focus} onFocusChange={(focus) => ... ... onDatesChange returns null #1953.
Read more >Airbnb react-dates returns null - Stack Overflow
I've tested it in codesandbox and it seems that onFocusChange is not getting triggered once the focus variable ends up being null.
Read more >react-dates onDatesChange startDate and endDate are null ...
Coding example for the question react-dates onDatesChange startDate and endDate are null, DayPickerRangeController-Reactjs.
Read more >@datepicker-react/hooks - npm
useDatepickerProps. onDatesChange: (data: OnDatesChangeProps) => void. A callback is triggered when the date is selected ( onDaySelect ).
Read more >DatePicker - Calcite React
return (. 27. <DatePicker. 28. id="basicDatePicker" ... {(touched.birthday && errors.birthday) || null} ... onDatesChange({ startDate, endDate }) {.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was running into a similar issue. The previous solution worked for me with a minor adjustment, which was pointed out here: https://github.com/airbnb/react-dates/issues/736#issuecomment-333237624
According to that, I adjusted the callback for the
onFocusChange
prop to the following:Based on the previous comments, my solution looks like the following:
@M1ck0 it should be:
focusedInput='startDate'
You code will be: