hypeserver / react-date-range

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

onRangeFocusChange used with DateRangePicker breaks usage of state.focusedRange #420

Open bertho-zero opened 3 years ago

bertho-zero commented 3 years ago

https://github.com/hypeserver/react-date-range/blob/33f2294eabc13f2413895faf9125e0cf0385dcad/src/components/DateRangePicker/index.js#L18

https://github.com/hypeserver/react-date-range/blob/33f2294eabc13f2413895faf9125e0cf0385dcad/src/components/DateRangePicker/index.js#L33

As soon as we define the onRangeFocusChange prop, it overwrites the internal function and the state is no longer updated

robbienohra commented 3 years ago

I'm having this issue as well

danielrussellLA commented 1 year ago

me too

danielrussellLA commented 1 year ago

a workaround for now:

const [focusedRange, setFocusedRange] = useState([0,0])

const onRangeFocusChange = (item) => {
  setFocusedRange(item)
}

<DatePicker
  focusedRange={focusedRange}
  onRangeFocusChange={onRangeFocusChange}
/>