react-native - 在 Native Base (React Native) 中的 Accordion 内容中的 JSX
问题描述
是否可以在本机基础的 Accordion 内容中包含 JSX 代码?
class MyAccount extends React.Component {
render() {
const creditCardContent = (
<Form>
<Item floatingLabel>
<Label>Name on Card</Label>
<Input />
</Item>
<Item floatingLabel>
<Label>Card Number</Label>
<Input />
</Item>
<Item floatingLabel>
<Label>CVC</Label>
<Input />
</Item>
<Item floatingLabel>
<Label>Zip Code</Label>
<Input />
</Item>
</Form>
);
const dataMenus = [
{ title: "Credit Card", content: creditCardContent },
{ title: "Bank Account (for ACH payments)", content: "Lorem ipsum dolor sit amet" },
{ title: "Recurring Payment", content: "Lorem ipsum dolor sit amet" }
];
return (
<Container>
<Content padder>
<ScrollView>
<Accordion dataArray={dataMenus} expanded={0}/>
</ScrollView>
</Content>
</Container>
);
}
}
我不确定我做错了什么还是不可能做的。谢谢
解决方案
据我所知,您可以使用renderContent
属性来定义它应该如何呈现。您可以将其作为常量或作为renderContent = (item) => { ... }
.
但是您现在正在做的是为 dataArray 提供 React.Element ,然后提供一堆它无法呈现的字符串。
推荐阅读
- android - Google 身份服务返回 16:未添加 Google 帐户时找不到匹配的凭据
- react-native - 如何自动聚焦到键盘 React Native?
- jestjs - 如何模拟调用 fetch() 并返回响应 obj 的函数?
- python - 将变量与json中的字符串进行比较
- android - PopUpWindow 忽略全屏和 CutoutMode
- ruby-on-rails - 在 Rails 6 中使用 config/credentials 的正确方法是什么?以及如何阻止我的应用程序使用 /tmp/development_secret?
- javascript - 预填充 PostgreSQL 数据库
- flutter - 如何在 Flutter 的屏幕顶部制作 bottomNavigationBar?
- dataframe - 如何在pyspark中将字符串日期转换为时间戳?
- json - 如何在 Julia 中将多个 JSON 文件加载到单个 DataFrame 中?