sbmdkl / nepali-datepicker-reactjs

20 stars 16 forks source link

Default date doesnt get updated #12

Open sjonchhe opened 2 years ago

sjonchhe commented 2 years ago

defaultDate doesnt update on rerender. it only works if default date exists in initial render

I have got 2 datepickers, I am trying to set default date of second date picker when date has been selected on the first datepicker. But default date on second datepicker doesnt get updated. Is there any workaround for this?

https://codesandbox.io/s/zen-monad-s5t7u5?file=/src/App.js

sbmdkl commented 2 years ago

The defaultDate is set once only when the component is mounted. The date is not updated then by changing defaultDate as the date value is changed with the user's interaction with the date in the calendar.

sbmdkl commented 2 years ago

For your two calendar cases, you can mount the other calendar component using defaultValue when the first calendar is set not both at the same time, or use a new key to force rerender the calendar.

nabanitkoirala commented 11 months ago

How can i set value of selected date,their is no props for adding value of selected field