2

I am using React Navigation Version 4 and after setting my navigations and all screens and run the code I am facing the following issue:

TypeError: (0, _reactNavigation.default) is not a function.

My Routes.Js is -

import React from 'react';
import createAppContainer from 'react-navigation';
import { createStackNavigator, HeaderBackButton } from 'react-navigation-stack';
import { Drawer } from './Drawer';
import LoginScreen from '../screens/LoginScreen';
import InitialScreen from '../screens/InitialScreen';
import LogoutScreen from '../screens/LogoutScreen';

const RootStack = createStackNavigator(
    {
        Drawer: { 
            screen: Drawer
        },
        LoginScreen: {
            screen: LoginScreen
        },
        LogoutScreen: {
            screen: LogoutScreen
        }
        InitialScreen: {
            screen: InitialScreen
        }
    },
    {
        initialRouteName: 'InitialScreen',
        headerMode: "none"
    }
)

const App = createAppContainer(RootStack);

export default App;

and Index.js is -

import React, { Component } from 'react';
import { StyleSheet, AsyncStorage } from 'react-native';
import { Button, Text, Drawer } from 'native-base';
import App from './config/Routes';
import AppHeader from './components/Header/Header';

export default class Index extends Component {
    render() {
        const { globalContainer } = styles;
        return (
            <App 
                style={ globalContainer } 
                navigation={this.props.navigation}>
            </App>
        )
    }
}

Any help??

1 Answer 1

6

It appears from the documentation that it should be a named import, not a default.

import { createAppContainer } from 'react-navigation';

Please read the docs. It's also a good first place to look when debugging.

Sign up to request clarification or add additional context in comments.

1 Comment

A similar error is also observed and fixed when importing connect from react-redux. The correct way to import would be import { connect } from react-redux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.