Bositkhon Sultonov
Bositkhon Sultonov

Reputation: 705

DrawerNavigator - Undefined is a function

When I run my android app on virtual device, It throws an error Undefined is not a function

I have tried to replace "AppDrawerNavigator" to "App" in my code, it solved the problem, but created another one 'Duplicate declaration "App"' error in console. Here is my code:

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import { DrawerNavigator } from 'react-navigation';
import HomeScreen from './screens/HomeScreen';

export default class App extends Component {
  render() {
    return (
      <AppNavigationDrawer />
    );
  }
}

const AppNavigationDrawer = DrawerNavigator({
  Home: {screen: HomeScreen},
  });

Error

undefined is not a function (evaluating '(0, _reactNavigation.DrawerNavigator)({ Home: {screen: _HomeScreen2.default}, });)

Upvotes: 1

Views: 1587

Answers (1)

Pritish Vaidya
Pritish Vaidya

Reputation: 22209

The DrawerNavigator doesn't seem to be in the named export in their main exports file in react-navigation@latest

Instead import it as createDrawerNavigator

import { createDrawerNavigator } from 'react-navigation';

Upvotes: 4

Related Questions