问题描述
我正在尝试理解 reactnavigation 并且我正在设置一个概念应用程序来理解.
i am trying to understand reactnavigation and i am setting up a concept app to understand.
我一开始遇到的困难是,我收到错误消息路由SomeRoute"的组件必须是 React 组件"
What i am struggling at first is, that i get the Error Message "The component for route "SomeRoute" must be a React Component"
我知道这意味着什么,但我不明白为什么会抛出这个错误.
I do know, what it means, but i do not understand why this error is thrown.
我有以下设置:
App.js:
import React from 'react';
import { Root } from './config/router';
import { SafeArea } from 'react-native';
class App extends Component {
render() {
return <Root />;
}
}
export default App;
router.js(config/router.js)
router.js( config/router.js )
import React from 'react';
import { DrawerNavigator, TabNavigator, StackNavigator } from 'react-navigation';
import Feed from './../components/Feed';
import Search from './../components/Search';
import Favorites from './../components/Favorites';
import TextList from './../components/ComingSoon';
import Detail from './../components/Detail';
import Downloads from './../components/Downloads';
export const FeedStack = StackNavigator({
Feed: {
screen: Feed,
navigationOptions: {
title: 'Machines'
}
},
List: {
screen: TextList,
navigationOptions: {
title: 'List View'
}
},
Detail: {
screen: Detail,
navigationOptions: {
title: 'Detail'
}
}
});
export const TabStack = TabNavigator({
Dashboard: {
screen: FeedStack,
navigationOptions: {
title: 'Dashboard'
}
},
Search: {
screen: Search,
navigationOptions: {
title: 'Search'
}
},
Favorites: {
screen: Favorites,
navigationOptions: {
title: 'Favorites'
}
}
});
export const DownloadStack = StackNavigator({
Downloads: {
screen: Downloads,
navigationOptions: {
title: 'Downloads'
}
}
});
export const Root = DrawerNavigator({
Feed: {
Screen: TabStack,
navigationOptions: {
title: 'Machines'
}
},
Downloads: {
screen: DownloadStack
}
});
和 Feed.js ( components/Feed.js )
and Feed.js ( components/Feed.js )
import React from 'react';
import { View, Text } from 'react-native';
class Feed extends React.Component {
render() {
return (
<View>
<Text>Hallo Feed Soon</Text>
</View>
);
}
}
export default Feed;
正如我所见,Feed 正在扩展 React.Component 并导出默认的类名Feed".
As i can see, Feed is extending React.Component and also exporting a default Classname "Feed".
这似乎是一个非常基本的错误,我在这里做错了什么?
It seems to be a very Basic Mistake, what am i doing wrong here?
推荐答案
好的,我找到了.
Root 中的路由Feed"具有Screen"属性而不是screen"属性.
The route "Feed" in Root has a "Screen" property instead of a "screen" Property.
可以在屏幕前错误关闭.
can be closed by error in front of screen.
这篇关于路由“Feed"的组件必须是 React 组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!