所以我有一个来自react-navigation
的rootstack导航我有一个像这样的index.js的文件夹:
import ExampleOne from './ExampleOne';
import ExampleTwo from './ExampleTwo';
import ExampleThree from './ExampleThree';
import ExampleFour from './ExampleFour';
import ExampleFive from './ExampleFive';
export {
ExampleOne,
ExampleTwo,
ExampleThree,
ExampleFour,
ExampleFive
};
使用ExampleOne.js到ExampleFive.js,如下所示:
import React, { Component } from 'react';
import { Container, Content, Text } from 'native-base';
export default class ExampleOne extends Component {
render() {
return (
<Container>
<Content>
<Text>Example</Text>
</Content>
</Container>
)
}
};
但是当我将它导入RootStack.js时,我收到错误“路由的组件'ExampleOne'必须是React组件。'
RoutStack.js是这样的:
import React from 'react';
import { createStackNavigator } from 'react-navigation';
// Import all MarketsScreen
import { ExampleOne, ExampleTwo, ExampleThree, ExampleFour, ExampleFive } from './Markets';
const RootStack = createStackNavigator({
ExampleOne: ExampleOne,
ExampleTwo, ExampleTwo,
ExampleThree: ExampleThree,
ExampleFour: ExampleFour,
ExampleFive: ExampleFive
});
export default RootStack;
我的代码有什么问题吗?我正在学习一些教程,但这对我不起作用
答案 0 :(得分:1)
尝试调用资源ExampleOne,ExampleTwo..etc,不应该使用对象{ExampleTwo} ..是不必要的..