内容中的刷新列表

问题描述 投票:0回答:1

我正在使用nativebase。

我想有一个下拉刷新列表。

我有一个AppContainer,其中包含页眉,页脚和内容:

   <Container>
        <StatusBar backgroundColor={colors.primary} />
        {renderHeader(this.props)}
        <Content contentContainerStyle={{ flexGrow: 1 }}>{this.props.children}</Content>
        {renderFooter(this.props)}
      </Container>

然后我在AppContainer中拥有了平面列表:

   <AppContainer>
      <TransactionList />
   </AppContainer>

[TransactionList是单位列表:

 <View style={styles.container}>
    <FlatList
      data={datas}
      extraData={this.state}
      renderItem={this.renderList}
      keyExtractor={item => item.item}
      onRefresh={this.refreshList}
      refreshing={this.state.refreshing}
    />
  </View>

但是由于AppContent内容是ScrollList,所以不显示请求刷新。

我该如何解决?

react-native react-native-flatlist native-base
1个回答
0
投票

[RefreshControl是react-native组件,官方的react-native文档已经使用ScrollView(https://facebook.github.io/react-native/docs/refreshcontrol)显示了它的示例,但它与FlatList的道具完全相同:

  return (
    <SafeAreaView style={styles.container}>
      <ScrollView
        contentContainerStyle={styles.scrollView}
        refreshControl={
          <RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
        }
      >
        <Text>Pull down to see RefreshControl indicator</Text>
      </ScrollView>
    </SafeAreaView>
  );
}
© www.soinside.com 2019 - 2024. All rights reserved.