react-component / calendar

React Calendar
http://react-component.github.io/calendar/
MIT License
1.7k stars 494 forks source link

Next/Prev month, Next / Last year button is not working for controlled component #839

Closed gogo1211 closed 3 years ago

gogo1211 commented 3 years ago

Hi, hope you are doing great.

I tried to use rc-calendar as following.

const [date, setDate] = useState(null)
....
<Calendar
  className="calendar"
  disabledDate={disableDate}
  showDateInput={false}
  showToday={false}
  showOk={false}
  value={date}
  onSelect={setDate}
/>

In this case, the month/year control buttons are not working. If I remove value={date}, then it works again.

Hope to hear from you soon.

Best

xrkffgg commented 3 years ago

https://github.com/react-component/calendar/blob/46a444449d2e3dc8077bc68a5f070a6dd2a9e36e/src/Calendar.jsx#L24

value should use moment type

gogo1211 commented 3 years ago

Thanks for the quick update, @xrkffgg

Just tried this but still the same.

const [date, setDate] = useState(moment())

github-actions[bot] commented 3 years ago

Hello @gogo1211. Please provide a online reproduction by forking this link https://codesandbox.io or a minimal GitHub repository.

gogo1211 commented 3 years ago

@xrkffgg Please try this one. https://codesandbox.io/s/confident-cdn-ub7qq

xrkffgg commented 3 years ago

calendar haven't maintained it for a long time

Try https://github.com/react-component/picker

gogo1211 commented 3 years ago

Will try. Thank you very much, @xrkffgg