onDateSelected returns same date everytime
See original GitHub issueI have a CalendarStrip which I want to use with a function that updates state every time the date is changed - I am trying to leverage it to display data depending on the day similar to Tabs. Each time a new date is selected onDateSelected returns the exact same moment timestamp.
Example: https://ibb.co/XDn7tPW
CalendarStrip (styling props removed):
<CalendarStrip
ref={(c) => { this._calendarStrip = c; }}
onDateSelected={date => console.log(date)}
selectedDate={this.props.startDateFormatted}
minDate={this.props.startDateFormatted}
maxDate={this.props.endDateFormatted}
datesWhitelist={[{
start: this.props.startDateFormatted,
end: this.props.endDateFormatted
}]}
/>
_onDateSelected:
_onDateSelected(date) {
this.setState({daySelected: date});
console.log(date);
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
HTML5 <input type=“date”> - onChange Event - Stack Overflow
The change event only occurs if the date picker has a valid date set and the value changes. The input event behaves exactly...
Read more >DatePicker | Superblocks Docs
Capture user inputted date and time. Use the selected date and time to create dynamic dashboards with Charts, or build forms that submit...
Read more >RadDatePicker OnDateSelected Loop in UI for ASP.NET AJAX
I have a RadDatePicker that if the user changes the date I have a confirm message to ask if the want to change...
Read more >Date picker - Pluralsight Design System
It is a controlled component with value . It takes an onSelect prop that returns a dayzed.DateObj each time a valid date is...
Read more >Filtering GeoJSON layer on Leaflet map based on date ...
There are several things wrong the way you are handling date data, so this is not really GIS related question but completely JS...
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
That’s a bit concerning and maybe a potential bug. Try to use Moment to format the date:
It could be that the built-in JS date formatter has an issue with Moment objects.
Try removing the
selectedDate
prop. It should work either way, but let’s rule that out at least.