【问题标题】:Implementing sticky headers inside a FlatList in React Native在 React Native 中的 FlatList 中实现粘性标头
【发布时间】:2020-08-10 17:03:36
【问题描述】:

我尝试在 FlatList 中实现粘性标头并遇到以下错误: undefined is not an object (evaluating '_this3.state.stickyHeaderIndices')

代码链接(小吃):https://snack.expo.io/@cmcodes/forlorn-cake

【问题讨论】:

    标签: javascript react-native react-native-flatlist sticky native-base


    【解决方案1】:

    此错误是由于它仅限于在您的 Explore Screen 类中使用,因为您使用功能组件来呈现列表,因此您必须在传递数据时传递粘性标题数据,即通过道具。

    您可以在以下位置查看更新的代码

    https://snack.expo.io/1JtMGGDd4

    【讨论】:

    • 知道了!谢谢!它完美地工作!必须使用第一个索引stickyHeaderIndices: [0], 初始化stickyHeaderIndices,否则会显示错误index=10 count 0
    猜你喜欢
    • 1970-01-01
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-25
    • 1970-01-01
    相关资源
    最近更新 更多