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.

Current month should update when passed values change

See original GitHub issue

Moving this conversation over from https://github.com/airbnb/react-dates/issues/17.

Because SingleDatePicker and DateRangePicker month props are controlled internally, there’s no way of programmatically changing the month once the component has already been mounted and used. https://github.com/airbnb/react-dates/issues/17 solves the initialVisibleMonth but there are still use cases not covered.

Examples:

  • A form has multiple datepickers. Even after initially opening, if one of the datepickers is selected, all the other form inputs should set their currentMonth to match
  • Allowing a HoC to control currentMonth will make it easier to arbitrarily jump n months back (see https://github.com/airbnb/react-dates/issues/29)

One proposal I have is to overhaul the API so that animation effects are triggered by watching for the currentMonth prop to change. We’d let a HoC always control the displayed month and pressing the “next month” button would just trigger a callback that the HoC would have to use to update currentMonth. Maybe if currentMonth is passed as a prop, use that instead of https://github.com/airbnb/react-dates/blob/master/src/components/DayPicker.jsx#L77?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:12
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
jabsatzcommented, Oct 23, 2017

I have the following setup:

A page with a list of ranges to select (This Month, Previous Month, Previous Year, etc.) and a DayPickerRangeController component, since you can also manually select these dates. So let’s suppose today is October 23rd, so I go back 3 months to July in the calendar, when I click on the “This Month” range the present month is selected, so October 1st through October 31st.

However the calendar is still showing July. I wouldn’t necesarily need it to change automatically, but there should at least be a way to pass in a “currentMonth” prop, with a “onChangeMonth” function to manipulate it from a parent. Is that possible?

1reaction
stahorcommented, Nov 9, 2018

@orouz yes but only by using my own fork

Read more comments on GitHub >

github_iconTop Results From Across the Web

Current month should update when passed values change #48
One proposal I have is to overhaul the API so that animation effects are triggered by watching for the currentMonth prop to change....
Read more >
passing values to onchange in react js - Stack Overflow
I want to display the "Current Month + year" in "Start Date" like "March 2020" and in "End Date" I want to display...
Read more >
Alter variable value for the current month to value of another ...
Solved: Hi All, I have a lookup table that I use to set variable to the correct month-end day for each month of...
Read more >
Validation Rule date can only be changed to date in the same ...
Validation Rule date can only be changed to date in the same month BUT not changed if the month has already passed. Save...
Read more >
Update automatically the value of current date (today)
Assuming that your DATE DE column is distinct this should always return the ATLDF value related to today's date. Br, J. Connect on...
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