我正在为本机应用程序使用本机基本扩展。我正在iOS模拟器上运行代码。
我一直在关注此事: http://nativebase.io/docs/v2.0.0/components#tabs
我的代码如下:
import React, { Component } from 'react';
import { Container, Header,Content, Tab, Tabs } from 'native-base';
import Profile from './Profile';
import Posts from './Posts';
export default class ProfileRoot extends Component {
render(){
return (
<Container>
<Header hasTabs />
<Tabs>
<Tab heading="Profile">
<Profile />
</Tab>
<Tab heading="Posts">
<Posts />
</Tab>
</Tabs>
</Container>
);
}
}
Profile和Posts组件都可以单独渲染(除了几个按钮之外,它们中没有多少)。我确信本机库已正确安装,因为我已经渲染了其他组件,如按钮。
我收到以下错误:
警告:React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:undefined。您可能忘记从其定义的文件中导出组件。请检查ProfileRoot
的呈现方法。
我已经在ProfileRoot中包含了导出默认类。有些事我很明显错过了我做错了什么?
答案 0 :(得分:0)
尝试按<Tabs>
标记或<Header>
标记包装<Content>
标记。
例:
<Header><Tabs>…</Tabs></Header>
答案 1 :(得分:-1)
尝试使用 view 标签和带有flex样式的样式包装标签和标题:1