rnc-archive / .github

This repository contains the general guidelines for the RNCommunity org
https://github.com/react-native-community
200 stars 31 forks source link

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. #55

Closed devika7 closed 5 years ago

devika7 commented 5 years ago

Question I am working on EXPO app which has predefined tabs. I added firebase authentication with a new page Loginscreen. js in the app. However, it is throwing error now in app.js file. Here is my App. js file

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

export default function App(props) { const [isLoadingComplete, setLoadingComplete] = useState(false);

if (!isLoadingComplete && !props.skipLoadingScreen) { return ( <AppLoading startAsync={loadResourcesAsync} onError={handleLoadingError} onFinish={() => handleFinishLoading(setLoadingComplete)} /> ); } else { return (

{Platform.OS === 'ios' && }
);

} }

async function loadResourcesAsync() { await Promise.all([ Asset.loadAsync([ require('./assets/images/robot-dev.png'), require('./assets/images/robot-prod.png'), ]), Font.loadAsync({ // This is the font that we are using for our tab bar ...Ionicons.font, // We include SpaceMono because we use it in HomeScreen.js. Feel free to // remove this if you are not using it in your app 'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'), }), ]); }

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

function handleFinishLoading(setLoadingComplete) { setLoadingComplete(true); }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', }, });

Error message

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of App.

Not really sure what I am doing wrong!!

THIS IS MY AppNavigator file

import React from 'react'; import {createAppContainer, createSwitchNavigator, createStackNavigator } from 'react-navigation'; import LoginScreen from '../screens/LoginScreen'; import MainTabNavigator from './MainTabNavigator';

const AppNavigator = createStackNavigator(

{ Login: LoginScreen},

{ Main: MainTabNavigator}, );

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

lucasbento commented 5 years ago

Hi @devika7, I would suggest opening a question on stackoverflow as this repository is meant for discussion regarding the react-native-community.