【问题标题】:stickyHeaderIndices does not work properly in an inverted FlatListstickyHeaderIndices 在倒置的 FlatList 中无法正常工作
【发布时间】: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


    【解决方案1】:

    我认为目前在 React Native 中是不可能的。我刚刚意识到这可能就是 Instagram 没有在他们的聊天中提供此功能的原因。

    如果将来有人阅读它知道正确的实现或解决方案,请回答。 现在,我只是放弃了在我的聊天应用程序的倒排列表上使用粘性标题的想法。谢谢:(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      相关资源
      最近更新 更多