Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.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
Javascript 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。自然反应_Javascript_Android_React Native_Npm_Yarnpkg - Fatal编程技术网

Javascript 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。自然反应

Javascript 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。自然反应,javascript,android,react-native,npm,yarnpkg,Javascript,Android,React Native,Npm,Yarnpkg,所以我一直在做大量的研究,来解释为什么这个方法不起作用,并且什么也找不到。 有人知道这个错误与什么有关吗 Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `App`. This

所以我一直在做大量的研究,来解释为什么这个方法不起作用,并且什么也找不到。 有人知道这个错误与什么有关吗

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
    
    Check the render method of `App`.
    
    This error is located at:
        in App (created by ExpoRoot)
        in ExpoRoot
        in RCTView (created by View)
        in View (created by AppContainer)
        in RCTView (created by View)
        in View (created by AppContainer)
        in AppContainer
    - node_modules\expo\build\logs\LogSerialization.js:160:14 in _captureConsoleStackTrace
    - node_modules\expo\build\logs\LogSerialization.js:41:26 in serializeLogDataAsync
    - ... 9 more stack frames from framework internals
这是我的App.js:

import * as Icon from '@expo/vector-icons'
import * as AppLoading  from 'expo-app-loading'
import {Asset} from 'expo-asset'
import * as Font from 'expo-font'
import React from 'react'
import { StatusBar, StyleSheet, View } from 'react-native'
import AppNavigator from './navigation/AppNavigator'

export default class App extends React.Component {
  state = {
    isLoadingComplete: false,
  }

  render() {
    if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
      return (
        <AppLoading
          startAsync={this._loadResourcesAsync}
          onError={this._handleLoadingError}
          onFinish={this._handleFinishLoading}
        />
      )
    } else {
      return (
        <View style={styles.container}>
          <StatusBar hidden />
          <AppNavigator />
        </View>
      )
    }
  }

  _loadResourcesAsync = async () => {
    return Promise.all([
      Asset.loadAsync([
        require('./assets/images/splash.png'),
        require('./assets/images/icon.png'),
      ]),
      Font.loadAsync({
        //This is the font that we are using for our tab bar
        ...Icon.MaterialIcons.font,
        ...Icon.MaterialCommunityIcons.font,
        ...Icon.FontAwesome.font,
        ...Icon.Feather.font,
      }),
    ])
  }

  _handleLoadingError = error => {
    // In this case, you might want to report the error to your error
    // reporting service, for example Sentry
    console.warn(error)
  }

  _handleFinishLoading = () => {
    this.setState({ isLoadingComplete: true })
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
  },
})
import*作为“@expo/vector icons”中的图标
从“expo应用程序加载”导入*作为应用程序加载
从“expo资产”导入{Asset}
从“expo字体”导入*作为字体
从“React”导入React
从“react native”导入{StatusBar,样式表,视图}
从“./navigation/AppNavigator”导入AppNavigator
导出默认类App扩展React.Component{
状态={
isLoadingComplete:false,
}
render(){
如果(!this.state.isLoadingComplete&!this.props.skipLoadingScreen){
返回(
)
}否则{
返回(
)
}
}
_loadResourcesAsync=async()=>{
回报你的承诺([
Asset.loadAsync([
需要(“./assets/images/splash.png”),
需要(“./assets/images/icon.png”),
]),
Font.loadAsync({
//这是我们用于选项卡栏的字体
…Icon.MaterialIcons.font,
…Icon.materialcommunitycons.font,
…Icon.fontsomesome.font,
…Icon.Feather.font,
}),
])
}
_handleLoadingError=错误=>{
//在这种情况下,您可能希望将错误报告给您的错误
//报告服务,例如哨兵
控制台。警告(错误)
}
_handleFinishLoading=()=>{
this.setState({isLoadingComplete:true})
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“#fff”,
},
})

我已经安装了所有必要的模块,重置了缓存,检查了导入语句,但似乎没有任何效果。

请遵循expo文档:

替换

import*作为从“expo应用程序加载”加载的应用程序

从“expo应用程序加载”导入应用程序加载


来解决您的问题。

请遵循世博会文档:

替换

import*作为从“expo应用程序加载”加载的应用程序

从“expo应用程序加载”导入应用程序加载


来解决您的问题。

效果很好!谢谢你,真是太棒了!非常感谢。