【发布时间】:2020-09-04 12:23:33
【问题描述】:
我仍然是原生反应的新手,并且正在开发一个聊天应用程序。我使用<FlatList /> 元素来显示一长串消息并添加inverted 属性,以默认显示最后的消息。
但是让我的 FlatList 倒置,扰乱了我用来显示消息日期的stickyHeaderIndices 的功能(就像他们在 WhatsApp 中所做的那样)。已经两天了,我被困在这上面了。
我还附上了我正在使用的<FlatList/> 的代码
<FlatList
style={{ flex: 1 }}
data={messageList}
renderItem={this.renderMessage}
keyExtractor={(item, index) => index.toString()}
showsVerticalScrollIndicator={false}
stickyHeaderIndices={stickyHeaders}
inverted
/>
其中变量messageList 是所有消息的数组,包括我希望显示的标题,this.renderMessage 显示单个消息,stickyHeaders 是一个数组,其中包含存储在messageList 中的标题索引.
【问题讨论】:
标签: react-native react-native-android react-native-ios react-native-flatlist