Skip to content

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

@shreesha

Description

@shreesha

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions