xcsob
xcsob

Reputation: 925

React-Navigation: Invariant Violation: Element type is invalid: expected a string but got undefined

I'm getting an error while using StackNavigator of React-Navigation.

Following I'm showing you my code, the version that I have, and all my configuration of package.json

Here is the code:

import {React} from 'react'
import { StackNavigator } from 'react-navigation';
import LoginForm from '../view/screen/LoginForm'
import Setting from '../view/screen/Setting'

export const AppNavigator = StackNavigator({
  Login: { screen: LoginForm },
  Setting: { screen: Setting }
});

This is my configuration:

 1. [email protected] 
 2. npm version: 5.6.0
 3. react-native-cli: 2.0.1
 4. react-native: 0.57.5

This is my package.json

  "dependencies": {
    "firebase": "^5.5.9",
    "react": "16.6.1",
    "react-native": "0.57.5",
    "react-native-elements": "^0.19.1",
    "react-native-navigation": "^2.2.0",
    "react-native-ui-lib": "^3.6.1",
    "react-navigation": "^1.0.0-beta.22",
    "react-redux": "^5.1.1",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0"
  }

The error is show in the screenshot

The App.js is. The 21 line is the one with the Provider Component. Look: without adding the StackNavigator I have no error.

import AppNavigator from "./routers/Router"

    render(){
        return (
            <Provider store={createStore(reducers, {}, applyMiddleware(ReduxThunk))}>
                <AppNavigator />
            </Provider>
        )
    }
}



export default App;

Upvotes: 0

Views: 1563

Answers (1)

xcsob
xcsob

Reputation: 925

The solution is to change export const in AppsNavigator with export default.

export default AppNavigator = StackNavigator({
  Login: { screen: LoginForm },
  Setting: { screen: Setting }
});

Upvotes: 1

Related Questions