【问题标题】:React Native FlatList is giving error that It doesnot be nested inside scrollViewReact Native FlatList 给出错误,它没有嵌套在 scrollView 中
【发布时间】:2020-10-09 12:59:58
【问题描述】:

我使用的是原生基础,错误在于它包含内置滚动视图的平面列表,无需将其嵌套到滚动视图中 图一代码:

<Container>
    <Content>
        <View>
            ***
        </View>
        <FlatList 
            {...props}
        />
    </Content>
</Container>

图2代码:

<View>
    <View>
        <View>
            ***
        </View>
        <FlatList 
            {...props}
        />
    </View>
</View>

我希望这两个部分都能正常滚动,有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: react-native react-native-flatlist native-base react-native-scrollview


    【解决方案1】:

    你需要稍微修改你的结构

    <View>
      <ScrollView>
        <View>
            ***
        </View>
        <FlatList 
            {...props}
        />
      </ScrollView>
    </View>
    

    【讨论】:

      【解决方案2】:

      nativebase 中的Content 基本上是一个滚动视图。

      您可以使用FlatList 的`页眉和页脚组件功能。并将 FlatList 上方的内容标记为 Header,将其下方的内容标记为页脚。

      const ContentAbove=()=>(
        <View>**</View>
      )
      
      //Then inside the component
      -----
      <Container>
          <FlatList
                  ListHeaderComponent={<ContentAbove/>}
                  ListFooterComponent={<ContentBelow/>}
                  {...props}
              />
      </Container>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-09-15
        • 2015-06-27
        • 1970-01-01
        • 1970-01-01
        • 2020-09-25
        • 1970-01-01
        • 2021-05-24
        • 2018-07-06
        相关资源
        最近更新 更多