react-native-calendar-strip
react-native-calendar-strip copied to clipboard
Calendar strip scrolls back to selectedDate when component re-renders.
I'm currently fetching new calendar dates for markedDates when onWeekChanged is triggered. If the component has a selectedDate, it thinks the selectedDate has changed on rerender, even though it has not which triggers it to scroll to selectedDate when markedDates changes.
I found this snippet in Scroller.js line 96 thanks to the latest post on this issue https://github.com/BugiDev/react-native-calendar-strip/issues/321#issuecomment-990067754
if (selectedDate !== prevProps.renderDayParams.selectedDate) {
this.scrollToDate(selectedDate);
}
Since selectedDate is using moment internally which is a function, this check is always true even if the dates are the same, regardless of being a moment variable or string. I was able to fix it by changing that condition to use moment's built in equal function.
if (!selectedDate.isSame(prevProps.renderDayParams.selectedDate)) {
this.scrollToDate(selectedDate);
}
I am using patch-package to fix this issue - anychance we could get this in? I could do a PR