shahabyazdi / react-multi-date-picker

a simple React datepicker component for working with gregorian, persian, arabic and indian calendars
https://shahabyazdi.github.io/react-multi-date-picker/
MIT License
766 stars 90 forks source link

How to change programmatically the current displayed month in the Calendar component #255

Open felixbores opened 7 months ago

felixbores commented 7 months ago

Hi there.

I'm using Calendar with numberOfMonths={2} and range props for custom range selection.

I have 2 text field inputs to manually enter the start and end dates. I want to change the Calendar current month displayed to the start date month entered, but I don't see a way to do it.

I tried changing the currentDate prop, but it didn't work (I looked into the repo code later and noticed that the value is stored in a ref and is not updated afterward).

abhishekram404 commented 3 months ago

Hello @felixbores, I am also facing this same issue. Did you ever find a solution for this?

felixbores commented 3 months ago

Hello @felixbores, I am also facing this same issue. Did you ever find a solution for this?

Hey To be honest I don't remember if, in the end, I implemented a solution. But one way this can be achieved would be by using key, so that if the start date changes (month or year), the key could be updated to force the component to be recreated again. I didn't test that idea, but I think it might work.

abhishekram404 commented 3 months ago

Thanks a lot for your response. I'll try using the key.