Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved performance on rendering 'day' with highlighted days #1180

Merged
merged 1 commit into from Dec 16, 2017

Conversation

alex-shamshurin
Copy link
Contributor

Highlight dates with custom class names and ranges, like this:

 { "react-datepicker__day--highlighted-custom-1": [
      moment().subtract(4, "days"),
      moment().subtract(3, "days"),
      moment().subtract(2, "days"),
      moment().subtract(1, "days") ]
    },
    { "react-datepicker__day--highlighted-custom-2": [
      moment().add(1, "days"),
      moment().add(2, "days"),
      moment().add(3, "days"),
      moment().add(4, "days") ]
    }

were calculated each time on day rendering and that caused slow performance with long arrays.

Now this array of objects is calculated just once in costructor and is kept in state as javascript flat Map of {dateString: className}

@codecov
Copy link

codecov bot commented Dec 16, 2017

Codecov Report

Merging #1180 into master will increase coverage by 0.47%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1180      +/-   ##
==========================================
+ Coverage   86.38%   86.86%   +0.47%     
==========================================
  Files          13       13              
  Lines         852      860       +8     
  Branches      143      139       -4     
==========================================
+ Hits          736      747      +11     
+ Misses         31       30       -1     
+ Partials       85       83       -2
Impacted Files Coverage Δ
src/calendar.jsx 85.36% <ø> (+1.11%) ⬆️
src/month.jsx 83.72% <ø> (ø) ⬆️
src/week.jsx 77.41% <ø> (ø) ⬆️
src/day.jsx 93.33% <100%> (+2.85%) ⬆️
src/date_utils.js 92.96% <100%> (+0.91%) ⬆️
src/index.jsx 89.72% <75%> (-1.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55f9bdb...c780c79. Read the comment docs.

@martijnrusschen martijnrusschen merged commit 87039ac into Hacker0x01:master Dec 16, 2017
Squar89 pushed a commit to Squar89/react-datepicker2 that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants