question-mark
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.

highlightDates does not updating

See original GitHub issue

Why highlightDates property changes doesn’t trigger component update? I have dynamic highlightDates array, after i update it, nothing happens, but should add some class to defined dates.

<DatePicker inline monthsShown={2} highlightDates={dates}

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ghostcommented, Mar 25, 2019

I got one solution, not perfect, but working. First, need to add ref to second datepicker:

<DatePicker inline monthsShown={2} ref={secondDatepickerRef} />

Then you can manipulate with component reference:

const dates = [format(new Date('2019-03-25'), 'MM.DD.YYYY')];
const highlightedDates = new Map();
dates.forEach(el => newMap.set(el, ['react-datepicker__day--highlighted']));
secondDatepickerRef.state.highlightDates = highlightedDates;

highlightDates should be Map instance, where first argument is a date and second - highlighted class.

1reaction
kevflynncommented, Jun 2, 2019

Possibly cleaner and less breaking for React - add a key property to the datepicker - this will force it to update itself. key={shortid.generate()}

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to refresh mat-calendar after changing the background of ...
put the mat-calendar component inside a div with the condition that the array of highlight dates is not undefined
Read more >
Conditional formatting not reading dates
I have a spreadsheet in which dates have been formatted as dates in the Home tab, and where I already tried using "Text...
Read more >
Automatically Highlight Dates from Last Month - Google Support
I need to be able to highlight the dates that are from the previous month so they trigger a visual showing which tasks...
Read more >
conditional formatting highlight dates 90 days or less
how do I get the formula to work for D2 through D55? BTW -- thank you for your help! I really appreciate it....
Read more >
How to work more productively online using new conditional ...
How to apply the rule online in Excel. Remember, we're working online, not in the desktop version. To apply a conditional formatting rule,...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found