Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React-day-picker show previous month when using numberOfMonths

I’m using the react-day-picker component and the numberOfMonths variable to set the month’s display.
The current display shows the current month and next month, but I’m trying to show the previous month and the current month.

Current Code

<DayPicker
  mode="range"
  selected={selectedRange}
  onSelect={handleRangeSelect}
  numberOfMonths={2}
/>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As per the documentation, you should use defaultMonth prop to change the initially displayed month. If you want to control the months yourself you can use the month prop instead of defaultMonth and use the onMontChange even to set it.

Link to the API reference

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading