@@ -68,8 +68,7 @@ const CalendarProvider = (props: CalendarContextProviderProps) => {
6868 const buttonY = useRef ( new Animated . Value ( todayBottomMargin ? - todayBottomMargin : - TOP_POSITION ) ) ;
6969 const opacity = useRef ( new Animated . Value ( 1 ) ) ;
7070 const today = useRef ( getTodayFormatted ( ) ) ;
71-
72- const [ prevDate , setPrevDate ] = useState ( date ) ;
71+ const prevDate = useRef ( date ) ;
7372 const [ currentDate , setCurrentDate ] = useState ( date ) ;
7473 const [ updateSource , setUpdateSource ] = useState ( UpdateSources . CALENDAR_INIT ) ;
7574 const [ isDisabled , setIsDisabled ] = useState ( false ) ;
@@ -92,14 +91,14 @@ const CalendarProvider = (props: CalendarContextProviderProps) => {
9291 /** Context */
9392
9493 const _setDate = useCallback ( ( date : string , updateSource : UpdateSources ) => {
95- setPrevDate ( currentDate ) ;
94+ prevDate . current = currentDate ;
9695 setCurrentDate ( date ) ;
9796 setUpdateSource ( updateSource ) ;
9897 setButtonIcon ( getButtonIcon ( date , showTodayButton ) ) ;
9998
10099 onDateChanged ?.( date , updateSource ) ;
101100
102- if ( ! sameMonth ( new XDate ( date ) , new XDate ( currentDate ) ) ) {
101+ if ( ! sameMonth ( new XDate ( date ) , new XDate ( date ) ) ) {
103102 onMonthChange ?.( xdateToData ( new XDate ( date ) ) , updateSource ) ;
104103 }
105104 } , [ currentDate , onDateChanged , onMonthChange ] ) ;
@@ -122,7 +121,7 @@ const CalendarProvider = (props: CalendarContextProviderProps) => {
122121 numberOfDays,
123122 timelineLeftInset
124123 } ;
125- } , [ currentDate , prevDate , updateSource , numberOfDays ] ) ;
124+ } , [ currentDate , updateSource , numberOfDays ] ) ;
126125
127126 /** Animations */
128127
0 commit comments