【发布时间】:2017-02-15 15:34:57
【问题描述】:
我正在为我的 react 本机应用程序使用本机基础扩展。我在我的 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:类型无效 - 应为字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义。您可能忘记从定义组件的文件中导出组件。检查ProfileRoot 的渲染方法。
我已经在 ProfileRoot 中包含了导出默认类。有什么我显然错过了什么我做错了什么?
【问题讨论】:
-
我认为您的问题与导出
Profile或Posts组件有关。你能展示你是如何导出你的组件的吗? -
而不是
Profile和Posts组件尝试插入按钮、文本或任何其他组件,如果它有效,则问题可能与Profile或Posts无关@987654330 @.