gpt4 book ai didi

react-native - 路由 "Feed"的组件必须是 React 组件

转载 作者:行者123 更新时间:2023-12-03 01:55:22 26 4
gpt4 key购买 nike

我正在尝试理解reactnavigation,并且我正在设置一个概念应用程序来理解。

我首先遇到的困难是,我收到错误消息“路由“SomeRoute”的组件必须是 React 组件”

我知道这意味着什么,但我不明白为什么会抛出这个错误。

我有以下设置:

应用程序.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)

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 (组件/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”。

这似乎是一个非常基本的错误,我在这里做错了什么?

最佳答案

好的,我找到了。

Root 中的路由“Feed”具有“Screen”属性,而不是“screen”属性。

可以因屏幕前的错误而关闭。

关于react-native - 路由 "Feed"的组件必须是 React 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49240212/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com