File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
src/expandableCalendar/Context Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ const CalendarProvider = (props: CalendarContextProviderProps) => {
5454 const {
5555 theme,
5656 date,
57+ onDateChanged,
58+ onMonthChange,
5759 showTodayButton = false ,
5860 todayBottomMargin,
5961 todayButtonStyle,
@@ -89,26 +91,26 @@ const CalendarProvider = (props: CalendarContextProviderProps) => {
8991
9092 /** Context */
9193
92- const _setDate = ( date : string , updateSource : UpdateSources ) => {
94+ const _setDate = useCallback ( ( date : string , updateSource : UpdateSources ) => {
9395 setPrevDate ( currentDate ) ;
9496 setCurrentDate ( date ) ;
9597 setUpdateSource ( updateSource ) ;
9698 setButtonIcon ( getButtonIcon ( date , showTodayButton ) ) ;
9799
98- props . onDateChanged ?.( date , updateSource ) ;
100+ onDateChanged ?.( date , updateSource ) ;
99101
100102 if ( ! sameMonth ( new XDate ( date ) , new XDate ( currentDate ) ) ) {
101- props . onMonthChange ?.( xdateToData ( new XDate ( date ) ) , updateSource ) ;
103+ onMonthChange ?.( xdateToData ( new XDate ( date ) ) , updateSource ) ;
102104 }
103- } ;
105+ } , [ currentDate , onDateChanged , onMonthChange ] ) ;
104106
105- const _setDisabled = ( disabled : boolean ) => {
107+ const _setDisabled = useCallback ( ( disabled : boolean ) => {
106108 if ( ! showTodayButton || disabled === isDisabled ) {
107109 return ;
108110 }
109111 setIsDisabled ( disabled ) ;
110112 animateOpacity ( disabled ) ;
111- } ;
113+ } , [ showTodayButton ] ) ;
112114
113115 const contextValue = useMemo ( ( ) => {
114116 return {
You can’t perform that action at this time.
0 commit comments