File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ export default class ExpandableCalendarScreen extends Component<Props> {
181181 render ( ) {
182182 return (
183183 < CalendarProvider
184- date = { ITEMS [ 0 ] . title }
184+ date = { ITEMS [ 1 ] . title }
185185 onDateChanged = { this . onDateChanged }
186186 onMonthChange = { this . onMonthChange }
187187 showTodayButton
Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ const Calendar = (props: CalendarProps) => {
8181 const [ currentMonth , setCurrentMonth ] = useState ( current || initialDate ? parseDate ( current || initialDate ) : new XDate ( ) ) ;
8282 const style = useRef ( styleConstructor ( theme ) ) ;
8383 const header = useRef ( ) ;
84+ const isMounted = useRef ( false ) ;
85+
8486
8587 useEffect ( ( ) => {
8688 if ( initialDate ) {
@@ -89,9 +91,14 @@ const Calendar = (props: CalendarProps) => {
8991 } , [ initialDate ] ) ;
9092
9193 useEffect ( ( ) => {
92- const _currentMonth = currentMonth . clone ( ) ;
93- onMonthChange ?.( xdateToData ( _currentMonth ) ) ;
94- onVisibleMonthsChange ?.( [ xdateToData ( _currentMonth ) ] ) ;
94+ if ( isMounted . current ) {
95+ // Avoid callbacks call on mount
96+ const _currentMonth = currentMonth . clone ( ) ;
97+ onMonthChange ?.( xdateToData ( _currentMonth ) ) ;
98+ onVisibleMonthsChange ?.( [ xdateToData ( _currentMonth ) ] ) ;
99+ } else {
100+ isMounted . current = true ;
101+ }
95102 } , [ currentMonth ] ) ;
96103
97104 const updateMonth = ( newMonth : XDate ) => {
You can’t perform that action at this time.
0 commit comments