Skip to content

Flat list onEndReached automatically render all the information #16322

@geniushwan5263

Description

@geniushwan5263

Is this a bug report?

No

Have you read the Contributing Guidelines?

No

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.4.0
Yarn: 0.27.5
npm: 5.4.0
Watchman: 4.7.0
Xcode: Xcode 8.3.3 Build version 8E3004b
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react-native: 0.48.1 => 0.48.1
react: 16.0.0-alpha.12 => 16.0.0-alpha.12

Target Platform: iOS (10.3), android (23)

Hello! I am actually pretty new to react native and I stuck on flat list.

Actually I implemented flat list like this with react navigation (tabs).

when I enter the tab, onEndReached start automatically although I did not scroll to the bottom.

please give me some tips to solve this.

these are my codes:

flat list:

return (

{console.log(this.state.comment)}

<FlatList
data={this.state.comment}
onEndReachedThreshold={0}
onEndReached={this._onEndReached}
renderItem={({ item }) => (
<ListItem
title={ item.comment }
subtitle={'\n\n\n' + this._getDay(item)}
/>
)}
keyExtractor={item => item.id}
/>

_onEndReached function (adding information to change state):

_onEndReached = () => {
if (!this.onEndReachedCalledDuringMomentum) {
this.setState({
page: this.state.page + 1 },
() => {
store.networkManager.requestUserCommentR(this.cbComment, this.state.page);
}
);
}
}

thank you for all!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions