TypeError: Cannot read property 'scrollToDate'
strelov1 opened this issue · comments
When I try to select another date with the ref I have this error
TypeError: Cannot read property 'scrollToDate'
Here is my configuration
const calendarRef = useRef(null);
const nextDay = () => {
if (calendarRef.current) {
const addOneDay = new Date(currentDate);
addOneDay.setDate(currentDate.getDate() + 1);
calendarRef.current.setSelectedDate(addOneDay.toISOString())
}
}
return (
<CalendarStrip
ref={calendarRef}
calendarAnimation={{type: 'sequence', duration: 30}}
style={styles.calendarStrip}
onDateSelected={onDateChange}
/>
)
You need to add scrollable={true} to your code. like this
<CalendarStrip
ref={calendarRef}
scrollable={true}
calendarAnimation={{type: 'sequence', duration: 30}}
style={styles.calendarStrip}
onDateSelected={onDateChange}
/>
Thanks @tanyicheng. It's helped