GhostPengy
GhostPengy

Reputation: 1024

React-navigation error when trying to set up after installing - Element type is invalid

I am new to react-native was fiddling around and came across need of navigation. However, after following directions on reactnavigation.org my emulator is spewing out a nonsensical error to me. Google had no help sadly this time.

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.

Check the render method of AwakeInDevApp.

Code is most simplistic example they have:

import React from 'react';
import {
  AppRegistry,
  Text,
} from 'react-native';
import { StackNavigator } from 'react-navigation';

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    return <Text>Hello, Navigation!</Text>;
  }
}

const EProj = StackNavigator({
  Home: { screen: HomeScreen },
});

AppRegistry.registerComponent('EProj', () => EProj);

Dependencies:

  "dependencies": {
    "expo": "^20.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.0",
    "react-navigation": "^1.0.0-beta.11"
  }

Upvotes: 0

Views: 86

Answers (1)

Antoine Grandchamp
Antoine Grandchamp

Reputation: 7461

It looks like you don't need AppRegistry.registerComponent('EProj', () => EProj); with Expo try simply exporting your module like this : export default EProj

Here is a link to a similar problem

Upvotes: 2

Related Questions