这是代码:
<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 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} />} />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)