React Native FlatList Pagination not working - onE

2019-02-20 03:02发布

问题:

I am using react-native FlatList component to list of items Pagination is not happening as expected , as per documentation onEndReached has to get fired when end of page is reached, currently I tried changing the values for onEndReachedThreshold ( tried 0.1, 1.0, 0.5, 0.01 ), am setting refreshing flag as well. Note: I am using ReactNative 0.48.4 So here my code

<Container style={{ marginTop: 22 }}>
      <Content
        style={{ flex: 1 }}
        contentContainerStyle={{ flexGrow: 1 }}
      >
        <View style={{ flex: 1 }}>
          <FlatList
            initialNumToRender={10}
            refreshing={this.state.refreshing}
            onEndReachedThreshold={0.5}
            onEndReached={({ distanceFromEnd }) => {
              console.log('on end reached ', distanceFromEnd);
            }}
            data={this.props.messages}
            renderItem={this.notificationContent.bind(this)}
            keyExtractor={(item) => item._id}
          />
        </View>
      </Content>
    </Container>

I have already tried all possible solutions as give in responses for github issues

Any Help here ?

回答1:

You use NativeBase in your project and the Flatlist is on Content they are conflict. To solve this problem you need to remove Content



回答2:

Pass extraData prop to FlatList as extraData = {this.state} check the docs for more info.



回答3:

onEndReachedThreshold={0.5}     remove this line