Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在App.js-React中将默认路由页面设置为主页时出错_Reactjs_React Native_Ecmascript 6_Es6 Class - Fatal编程技术网

Reactjs 在App.js-React中将默认路由页面设置为主页时出错

Reactjs 在App.js-React中将默认路由页面设置为主页时出错,reactjs,react-native,ecmascript-6,es6-class,Reactjs,React Native,Ecmascript 6,Es6 Class,我对React Native不熟悉,我想在我的应用程序中将默认屏幕设置为主屏幕 这是我的主页组件 import React, {Component} from 'react'; import {Text, View} from 'react-native'; class Home extends Component { render() { return ( <View> <Text>Hello! I'm Home component&

我对React Native不熟悉,我想在我的应用程序中将默认屏幕设置为主屏幕

这是我的主页组件

import React, {Component} from 'react';
import {Text, View} from 'react-native';

class Home extends Component {
  render() {
    return (
     <View>
      <Text>Hello! I'm Home component</Text>
     </View>
   );
  }
}

export default Home
构建后,它在emulator中抛出以下错误


路由“home”的组件必须是React组件。谁能告诉我哪里做错了。

你在App.js中错误地导入了Home

它应该是
import Home from./app/components/Home'

默认导出不需要在导入它们的文件中进行分解

本文可以提供更多的见解:

如下所示:

import Home from './app/components/Home';

因为在您的
主页
组件中,您使用了
导出默认值
,因此,我们必须像那样导入它。我想你应该看看这个:是的。。我没注意到。与角度不同,它是不同的
import Home from './app/components/Home';