hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.57k stars 658 forks source link

customDayRenderer and onShownDateChange to lazy load data for visualization #527

Open raDiesle opened 2 years ago

raDiesle commented 2 years ago

Subject of the issue

To highlight days and show additional information, we cannot load the data from year 1900 to 2200 as its big. So we need to load chunks of information to customDayRenderer based on the current month/year the user navigated to.

it works with useRef and passing information, between the handlers, but only if customDayRenderer is called again, e.g. when user mouse hovers the dates.

  1. Can we pass shownDate "from" and "to" to customDayRenderer and have it async?
  2. if 1. is rejected: How can I manual trigger event so "customDayRenderer" is triggered programmatically? - Ideally, when "shownDateChanged", it automatically triggers "customDayRenderer" automatically. Right now I did with a hack by toggling "showSelectionPreview", which works for range, but not for picker ( it will not change the rendered month view)
  3. the onShownDateChange handler should be triggered also when initially opened, especial when the range will change the shownDate automatically, so you know whats displayed right now

Environment

Package Version: 1.4.0 React version: 17.0.2 Node version: 14.13.0 Browser: Chrome