react-native-calendars: Cant scroll CalendarList inside BottomSheet in Android

Description

Hi, i am using CalendarList inside the BottomSheetModal, in iOS works well but in android i can’t scroll

"@gorhom/bottom-sheet": "4.1.5",
"react-native-calendars": "^1.1277.0",

Expected Behavior

Hi, i am using CalendarList inside the BottomSheetModal, in iOS works well but in android i can’t scroll because react-native-calendars using flatList from ‘react-native’, i changed import of the FlatList from 'react-native to ‘react-native-gesture-handler’ and it works well. How can i fix that without changing code in node modules?

Environment

Emulator Pixel XL 4/ Android

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 15

Most upvoted comments

I solving by add props to bottomsheet

`
<BottomSheet enableContentPanningGesture={false}

… </BottomSheet> `

This solution works for me:

import { CalendarList } from 'react-native-calendars';
import { FlatList } from 'react-native-gesture-handler';
(...)
<CalendarList style={styles.calendarList}
            calendarWidth={width - 30}
            calendarHeight={350}
            onDayPress={onDaySelect}
            scrollEnabled={true}
            markedDates={markedDates}
            customComponent={FlatList} />             // add FlatList from react-native-gesture-handler
(...)

@erickcrus - How do this work for you? customComponent is not a prop that CalendarList accepts?

I added the property customComponent to node_modules/react-native-calendars/src/calendar-list/index.tsx, you can see details in https://github.com/wix/react-native-calendars/commit/f74d0f6a554257f7a69b80f4ed4eba6f2953263a

pull request: https://github.com/wix/react-native-calendars/pull/2331

This solution works for me:

import { CalendarList } from 'react-native-calendars';
import { FlatList } from 'react-native-gesture-handler';
(...)
<CalendarList style={styles.calendarList}
            calendarWidth={width - 30}
            calendarHeight={350}
            onDayPress={onDaySelect}
            scrollEnabled={true}
            markedDates={markedDates}
            customComponent={FlatList} />             // add FlatList from react-native-gesture-handler
(...)

@erickcrus - How do this work for you? customComponent is not a prop that CalendarList accepts?

<BottomSheetFlatList data={[0]} renderItem={() => ( <CalendarList customHeader={(date) => ( <CustomHeader month={date.month.toString(‘MMMM’)} year={date.month.getFullYear()} /> )} pastScrollRange={0} futureScrollRange={3} scrollEnabled={true} showScrollIndicator={false} markingType={‘custom’} dayComponent={(date, item, marking) => CustomDayComponent(date, item, marking) } markedDates={tempDates.markedDates} firstDay={1} calendarStyle={styles.container} dayTextFontSize={moderateScale(50)} minDate={ new Date(new Date().setDate(new Date().getDate() + 1)) .toISOString() .split(‘T’)[0] } maxDate={new Date(tempDates.maxDate).toISOString().split(‘T’)[0]} disableAllTouchEventsForDisabledDays={true} hideDayNames={true} theme={{ textDayFontSize: moderateScale(15), textMonthFontSize: moderateScale(14), textDayFontFamily: FONTS.Inter_600SemiBold, textMonthFontFamily: FONTS.Inter_600SemiBold, dayTextColor: ‘black’, todayTextColor: ‘#d9e1e8’, textDisabledColor: ‘#d9e1e8’ }} /> )} />

i solved the problem like this just Render the CalendarList component inside BottomSheetFlastList

This solution works for me:

import { CalendarList } from 'react-native-calendars';
import { FlatList } from 'react-native-gesture-handler';
(...)
<CalendarList style={styles.calendarList}
            calendarWidth={width - 30}
            calendarHeight={350}
            onDayPress={onDaySelect}
            scrollEnabled={true}
            markedDates={markedDates}
            customComponent={FlatList} />             // add FlatList from react-native-gesture-handler
(...)