BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
944 stars 327 forks source link

Getting Component exception: TypeError: undefined is not an object (evaluating '_this.scroller.scrollToDate') when updateWeekView is called #295

Open shreesha opened 3 years ago

shreesha commented 3 years ago

Hi,

My calenderstrip component is as beow: <CalendarStrip scrollable scrollerPaging upperCaseDays={false} leftSelector={[]} rightSelector={[]} calendarAnimation={{ type: 'sequence', duration: 30 }} daySelectionAnimation={{ type: 'background', duration: 300, highlightColor: '#9265DC', }} style={{ height: 110, paddingTop: 20, paddingBottom: 10 }} calendarHeaderStyle={{ color: 'black', fontSize: 24, fontFamily: 'NunitoSans-Bold', alignItems: 'flex-start', marginBottom: 20, }} calendarColor={'white'} iconContainer={{ flex: 0.1 }} customDatesStyles={getCustomStyleForADate} markedDates={markedDates} onDateSelected={onDateSelected} onWeekChanged={onWeekChanged} onHeaderSelected={onHeaderSelected} useIsoWeekday={true} ref={calComp} />

Upon getting focus on the screen, I am using the ref and calling updateWeekView as below: useFocusEffect( React.useCallback(() => { if (calComp.current) { calComp.current.updateWeekView(moment().weekday(0)); }

}, []),

);

But, if I comment this out and load the page and uncomment the updateWeekView call and navigate back to the same page, it wont throw this exception.