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
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);
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);
}
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.
node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:5715:8 in createFiberFromTypeAndProps
node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:5743:14 in createFiberFromElement
... 8 more stack frames from framework internals
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.
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 (
} }
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.