gpt4 book ai didi

listview - React Native嵌套ListView在加载时多次触发onEndReached

转载 作者:行者123 更新时间:2023-12-03 04:42:37 24 4
gpt4 key购买 nike

代码如下:

<ScrollView>
{ tree.myPoiComments.CommentInfo && tree.myPoiComments.CommentInfo.length>0 &&
<FlatList
data={tree.myPoiComments.CommentInfo}
keyExtractor = {(item, index) => item.CommentId}
ListHeaderComponent = {() => <View>
<Text style={styles.listHeader}>My Comments</Text>
</View>}
renderItem= {({item}) => <CommentItem comment={item} owner={1} />}
/>
}
{ tree.poiComments.CommentInfo && tree.poiComments.CommentInfo.length>0 &&
<FlatList
data={tree.poiComments.CommentInfo}
keyExtractor = {(item, index) => item.CommentId}
onEndReachedThreshold={1}
onEndReached={(info) => {
alert(JSON.stringify(info));
} }
extraData = {this.state}
bounces={false}
ListHeaderComponent = {() => <View>
<Text style={styles.listHeader}>People's Comments</Text>
</View>}
renderItem= {({item}) => <CommentItem comment={item} owner={0} />}
/>
}
</ScrollView>

我已经浏览了 React Native 的 github 中的问题列表。当 ScrollView 被包裹时,onEndReached 将无法正常工作。我尝试了我找到的所有方法,但没有成功。

我只需要 FlatList 显示数据。两个列表单独滚动不是我想要的。这就是为什么我需要 ScrollView。看来嵌套是不可避免的了。有办法解决吗?

最佳答案

这就是我的平面列表的样子,并且工作正常。

https://github.com/facebook/react-native/issues/16067

    <FlatList
onEndReachedThreshold={ 0.5 }
onEndReached={ () => this.onEndReached() }
refreshing= { false }
onRefresh={ ()=> {
this.refetchData()
} }
data={this.state.data}
renderItem={({ item }) => <Item id={item.key} />} />

关于listview - React Native嵌套ListView在加载时多次触发onEndReached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48940820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com