Vaibhav Herugu
Vaibhav Herugu

Reputation: 1102

TypeError: (0, _reactNavigationDrawer.createAppContainer) is not a function: React Native Error

So I am trying to code tab navigation and when writing DrawerNavigation.js I encounter an error. I am a programmer in React Native, and the emulator is giving an error:

enter image description here

Here are my two files:

DrawerNavigator.js:

    import * as React from 'react';
    import {Platform, Dimensions} from 'react-native';
    import {
      createDrawerNavigator,
      createAppContainer,
    } from 'react-navigation-drawer';

    import ShopScreen from '../ShopScreen';

    const WIDTH = Dimensions.get('window').width;

    const DrawerNavigator = createDrawerNavigator(
      {
        Shop: ShopScreen,
      },
      {
        initialRouteName: 'Shop',
        contentOptions: {
          activeTintColor: '#e91e63',
        },
      },
    );

    export default createAppContainer(DrawerNavigator);


HomeScreen.js:

    import * as React from 'react';
    import DrawerNavigator from './navigation/DrawerNavigation';

    class HomeScreen extends React.Component {
      render() {
        return (
            <DrawerNavigator />
        );
      }
    }
    export default HomeScreen;

If you have an answer or any progress on the error, please tell me. Thanks!

Upvotes: 3

Views: 550

Answers (1)

Goskula Jayachandra
Goskula Jayachandra

Reputation: 4201

you were import createAppContainer wrongly, try this:

change

import {createDrawerNavigator, createAppContainer,} from 'react-navigation-drawer';

to

import { createAppContainer } from 'react-navigation';
import { createDrawerNavigator} from 'react-navigation-drawer';

Hope this helps!

Upvotes: 2

Related Questions