Search code examples
react-native

How to scroll FlatList in Modal component?


My Horizontal FlatList doesn't scroll in Modals. You can find my FlatList and RenderItem codes below:

    <FlatList
        data={this.props.selectedGroupData.groupMembersList}
        renderItem={this.ilgiliKisiler}
        keyExtractor={item => item.uid}
        nestedScrollEnabled={true}
        horizontal={true}
        removeClippedSubviews={true}
        />

    </View>

and renderItem function:

    ilgiliKisiler = ({ item }) => {
    console.log("on Related Users item => ", item);
    return (
      <TouchableOpacity style={{flex: 1}}>
        <View style={{ flexDirection: "row" }}>
          <View style={styles.relatedUsersContainer}>
            <View style={{ alignItems: "center" }}>
              <Image
                source={
                  item.avatar
                    ? { uri: item.avatar }
                    : require("../../assets/images/defaultAvatar.png")
                }
                style={styles.relatedUsersImage}
              />
            </View>
            <View style={{ flexDirection: "column" }}>
              <Text style={styles.relatedUsersText} numberOfLines={2}>
                {item.name}
              </Text>
            </View>
          </View>
        </View>
      </TouchableOpacity>
    );
  };

Before this post, i found some solutions like style={{flex: 1}}. When i try to this solutions, my renderItem doesn't appear.


Solution

  • Use propagateSwipe props for smooth scrolling in <Modal>

    <Modal propagateSwipe>...</Modal>
    

    for more detail react-native-modal issue #236