如何在本机反应中设置 FlatList 的刷新指示器?

新手上路,请多包涵

我正在尝试在本机反应中设置平面列表的刷新指示器,但不知道该怎么做。列表视图有这个道具:

 refreshControl={<RefreshControl
                        colors={["#9Bd35A", "#689F38"]}
                        refreshing={this.props.refreshing}
                        onRefresh={this._onRefresh.bind(this)}
                    />
                }

但是平面列表只有这些:

 refreshing={this.props.loading}
onRefresh={this._onRefresh.bind(this)}

原文由 AhmadReza 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 716
2 个回答

我找到了解决方案!它可能是假的,但 FlatList 也有一个类似于 ListView 的名为 refreshControl 的道具,但我只是没有测试它!像这样:

  <FlatList
    refreshControl={<RefreshControl
                    colors={["#9Bd35A", "#689F38"]}
                    refreshing={this.props.refreshing}
                    onRefresh={this._onRefresh.bind(this)} />}
 />

原文由 AhmadReza 发布,翻译遵循 CC BY-SA 4.0 许可协议

您可以将 renderScrollComponent 传递给您的 FlatList 组件,使用与上面显示的相同的 RefreshControl 组件。我为此创建了一个博览会小吃: https ://snack.expo.io/rJ7a6BCvW

FlatList 在自身内部使用 VirtualizedList,对于 VirtualizedList 组件,它需要一个 renderScrollComponenthttps ://facebook.github.io/react-native/docs/virtualizedlist.html#renderscrollcomponent

原文由 dotcomXY 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题