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

Updated month prop not updating the calendar when displaying multiple months #580

Closed
geminiyellow opened this Issue Dec 4, 2017 · 4 comments

Comments

2 participants
@geminiyellow

geminiyellow commented Dec 4, 2017

6.x it work very well, but when i update to 7.x, the month cannot causes the calendar to re-render when its value changes.

i save the month in component's state, and it looks like: http://react-day-picker.js.org/examples/elements-year-navigation

but i set the numberOfMonths to 2. and then setState from captionElement.
the logs:

image

in handleChange i got the right date, 201706, then setState to component,
then the captionElement got the 201711 and 201712.

then i try to change not use state cause picker rerender, change to showMonth.
now it work.

ok, then i read the docs, and try to use onMonthChange to keep the currentMonth to the state, but WTF, you see that? captionElement use the old values.

there is no BREAKINGCHANGE in the CHANGELOG and there is no docs in anywhere.
so , i cannot use 7.x. @gpbl could you help me ?

my code:

image

@geminiyellow

This comment has been minimized.

Show comment
Hide comment
@geminiyellow

geminiyellow Dec 4, 2017

ok, now i can say that is a bug.

from here: Fixed render of months when toMonth equals current month

@hydrognomik add this

+    } else if (props.toMonth && props.numberOfMonths > 1) {
+      const diffInMonths = Helpers.getMonthsDiff(props.toMonth, currentMonth);
+      if (diffInMonths <= 0) {
+        currentMonth = DateUtils.addMonths(
+          props.toMonth,
+          1 - this.props.numberOfMonths
+        );
+      }

Helpers.getMonthsDiff(props.toMonth, currentMonth) my toMonth is 201712, currentMonth is 201709, then the diffInMonths is -3, why you need to reset the currentMonth ? that is not right.

you should swap it to Helpers.getMonthsDiff(currentMonth, props.toMonth)

geminiyellow commented Dec 4, 2017

ok, now i can say that is a bug.

from here: Fixed render of months when toMonth equals current month

@hydrognomik add this

+    } else if (props.toMonth && props.numberOfMonths > 1) {
+      const diffInMonths = Helpers.getMonthsDiff(props.toMonth, currentMonth);
+      if (diffInMonths <= 0) {
+        currentMonth = DateUtils.addMonths(
+          props.toMonth,
+          1 - this.props.numberOfMonths
+        );
+      }

Helpers.getMonthsDiff(props.toMonth, currentMonth) my toMonth is 201712, currentMonth is 201709, then the diffInMonths is -3, why you need to reset the currentMonth ? that is not right.

you should swap it to Helpers.getMonthsDiff(currentMonth, props.toMonth)

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Dec 4, 2017

Owner

Thanks @geminiyellow ! Thanks for finding out the bug and the solution 👍 Going to release a fix ASAP

Owner

gpbl commented Dec 4, 2017

Thanks @geminiyellow ! Thanks for finding out the bug and the solution 👍 Going to release a fix ASAP

@gpbl gpbl changed the title from `7.x` 's `month` cannot `causes the calendar to re-render when its value changes` to Updated month prop not updating the calendar when displaying multiple months Dec 4, 2017

@gpbl gpbl closed this in #581 Dec 4, 2017

@geminiyellow

This comment has been minimized.

Show comment
Hide comment
@geminiyellow

geminiyellow commented Dec 4, 2017

wow thank you @gpbl

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Dec 4, 2017

Owner

Fix published in v7.0.5!

Owner

gpbl commented Dec 4, 2017

Fix published in v7.0.5!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment