本地基本手风琴,VirtualizedLists警告

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

我正在尝试使用Native Base中的Accordion,它返回了一个奇怪的警告。

我的代码:

const dataMenus = [
  { title: "Credit Card", content: "Lorem ipsum dolor sit amet" },
  { title: "Bank Account (for ACH payments)", content: "Lorem ipsum dolor sit amet" },
  { title: "Recurring Payment", content: "Lorem ipsum dolor sit amet" }
];
class MyAccount extends React.Component {
    render() {
      return (
        <Container>
          <Content padder>
            <ScrollView>
              <Accordion dataArray={dataMenus} expanded={0}/>
            </ScrollView>
          </Content>
        </Container>
      );
    }
}

返回:VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead.

谢谢

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

您可以尝试添加renderContent道具,如下所示:

  renderSecondaryContent = ( item ) => {
    return (
      <ScrollView
        style={{
          padding: 10,
          // height: 300
        }}
        horizontal={true}
      >
        <Text>{item}</Text>
      </ScrollView>
    );
  }

  render() {
    return (
      <Container style={styles.container}>
        <Content
          // style={{ maxHeight: 200 }}
          padder
        >
          <Accordion
            dataArray={dataMenus}
            expanded={0}
            renderContent={(dataMenus) => this.renderSecondaryContent(dataMenus.content)}
          />
        </Content>
      </Container>
    );
  }

我还添加了小吃here,您可以在这里进行进一步的尝试。 :)

© www.soinside.com 2019 - 2024. All rights reserved.