Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onDateSelected returns same date everytime

See original GitHub issue

I 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.


CalendarStrip (styling props removed):

   ref={(c) => { this._calendarStrip = c; }}
   onDateSelected={date => console.log(date)}
      start: this.props.startDateFormatted,
      end: this.props.endDateFormatted


_onDateSelected(date) {
    this.setState({daySelected: date});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

peacechencommented, Dec 3, 2018

That’s a bit concerning and maybe a potential bug. Try to use Moment to format the date:

   onDateSelected={date => console.log(date.format('MM-DD-YYYY')}

It could be that the built-in JS date formatter has an issue with Moment objects.

peacechencommented, Nov 30, 2018

Try removing the selectedDate prop. It should work either way, but let’s rule that out at least.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found