-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix duplicate months #279
Fix duplicate months #279
Conversation
75f5812
to
18598a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending one comment
const collisions = months | ||
.map(m => m.format('YYYY-MM')) | ||
.reduce((acc, m) => Object.assign( | ||
{}, acc, { [m]: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the invocation parens and every argument can't fit on one line, then each argument must be on a line by itself.
} else { | ||
newMonths = months.slice(0, numberOfMonths + 3); | ||
} | ||
newMonths = getMonths(initialMonth, numberOfMonths); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, I think the reason for this was to not create hella new moment objects when you changed the number of months which I think getMonths does, but I suppose that's a fairly rare edgecase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit to me after Jordan's comment has been addressed and tests/linting is addressed
18598a4
to
7a04a73
Compare
7a04a73
to
f792540
Compare
Thanks, fixed the lint and spec issues, ptal |
to: @majapw @ljharb
This PR fixes two issues related to duplicate months in
CalendarMonthGrid
:numberOfMonths
, the last month was duplicated in the first iteration of this loop. I simplified to reuse thegetMonths
logic instead of updating piecemeal. This should only be called whennumberOfMonths
changes, and it shouldn't affect the original perf improvements.CalendarMonth
key to allow more than 12 months. Otherwise, React will only render the first occurrence and printWarning: flattenChildren(...): Encountered two children with the same key
.