Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onEndReached Not called every time #41

Open
ghost opened this issue Feb 20, 2023 · 2 comments
Open

onEndReached Not called every time #41

ghost opened this issue Feb 20, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 20, 2023

I want load more data from firebase as my previous project I Used same method and same code it's working perfectly;but right now it was not working onEndReached called only one time after scroll bottom to top it's not called.

How To Load more data in flatlist?

I have attached my source code here.

let me know what should I do?

Thank You

        <FlatList
        enableAutoscrollToTop={false}
        showsVerticalScrollIndicator={false}
        ref={ref => (this.flatList = ref)}
        onContentChange={this.scrollToEnd}
        data={this.state.messages}
        inverted
        style={{marginBottom: hp(2.5)}}
        onEndReached={() => this.loadMoreOlderMessages()}
        renderItem={({item, index}) => {
          var isMyMessage =
            this.props.user.userDetails.id == item.user._id ? true : false;
          return (
            <Message
              item={item}
              key={index}
              OnlIds={this.state.dates.map(item => item?.id)}
              isLeft={isMyMessage ? false : true}
              message={item?.text}
              onSwipe={(text, isLeft) => {
                this.props.user?.userDetails?.isCommunityChatBlock
                  ? null
                  : this.swipeToReply(text, isLeft, item, this.flatList);
                setTimeout(() => {
                  this.inputRef?.focus();
                }, 0);
              }}
            />
          );
        }}
        keyExtractor={item => item.id}
        HeaderLoadingIndicator={() => null}
        onStartReachedThreshold={10} // optional
        onEndReachedThreshold={0.1}
        initialNumToRender={15}
      />
        
loadMoreOlderMessages = async () => {
await ChatController.loadMoremessagesData({
  path: `${COLLECTIONS.COMMUNITYMESSAGES}`,
})
  .then(response => {
    if ('data' in response) {
      if (response.data.length > 0) {
        response.data.map(item => {
          this.callBack({data: {data: item, type: 'added'}}, false);
        });
      } else {
      }
    } else {
    }
  })
  .catch(error => {
    return;
  });

};

@krmao
Copy link

krmao commented Oct 16, 2023

onEndReachedThreshold=100

@Gand4lf
Copy link

Gand4lf commented Feb 23, 2024

I'm getting the same issue. Have you found any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants