简体   繁体   中英

cannot scroll native-base FlatList inside ScrollView

im using native base for my component, so the case is i have DropdownBox/Select then i have FlatList but i want the FlatList scrolling is to follow the parent scrollview scrolling so if i scroll the FlatList then the DropdownBox move along as the list scrolled but my list won't even scroll i don't know why

 <ScrollView
  showsVerticalScrollIndicator={false}
  contentContainerStyle={{ width: "100%", alignItems: "center" }}
>
  <Stack flexWrap={"wrap"} justifyContent="center">
    <SelectBox />
    <FlatList
      mt={"4"}
      showsVerticalScrollIndicator={false}
      data={data}
      keyExtractor={(item, index) => index}
      numColumns={2}
      renderItem={(data, index) => {
        return <PortfolioCard />;
      }}
    />
  </Stack>
</ScrollView>

在此处输入图像描述

i'm not sure your question, maybe can you give a video detail,

<ScrollView
  showsVerticalScrollIndicator={false}
  nestedScrollEnabled // add this
  contentContainerStyle={{ width: "100%", alignItems: "center" }}
>
  <Stack flexWrap={"wrap"} justifyContent="center">
    <SelectBox />
    <FlatList
      mt={"4"}
      showsVerticalScrollIndicator={false}
      data={data}
      nestedScrollEnabled
      style={{height: 300}} // also this
      keyExtractor={(item, index) => index}
      numColumns={2}
      renderItem={(data, index) => {
        return <PortfolioCard />;
      }}
    />
  </Stack>
</ScrollView>

It is not recommended to use Flatlist inside ScrollView . Use ListHeaderComponent instead.

<FlatList
  mt={"4"}
  showsVerticalScrollIndicator={false}
  data={data}
  ListHeaderComponent={<SelectBox />}
  style={{height: 300}}
  keyExtractor={(item, index) => index}
  numColumns={2}
  renderItem={(data, index) => {
    return <PortfolioCard />;
  }}
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM