everyone, I have been trying to make my drawer navigation code work and it was saying that createAppContainer was undefined and that it wasn't a function. So after some research, I tried to change react-navigation versions and another error persisted loading my bundler at only 19%. Below I will post a screenshot of both errors from 3 react-navigation versions.

I have tried running the code with "react-navigation": "^2.18.3" the error was:

(In '(0, _reactNavigation.createAppContainer)(navigator)', '(0, _reactNavigation.createAppContainer)' is undefined)

<unknown>
    App.js:46:34
loadModuleImplementation
    require.js:331:6
<unknown>
    index.js:7
loadModuleImplementation
    require.js:331:6
guardedLoadModule
    require.js:197:45
global code
    <unknown file>:0
"

As for "react-navigation": "^3.0.7" and "react-navigation": "^3.8.1" the errors were:

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `./createNavigationContainer` from `/Users/camillebasbous/Project/node_modules/react-navigation/src/react-navigation.js`: The module `./createNavigationContainer` could not be found from `/Users/camillebasbous/Project/node_modules/react-navigation/src/react-navigation.js`. Indeed, none of these files exist:
  * `/Users/camillebasbous/Project/node_modules/react-navigation/src/createNavigationContainer(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
  * `/Users/camillebasbous/Project/node_modules/react-navigation/src/createNavigationContainer/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)` (null))

__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.228
    RCTCxxBridge.mm:414
___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
-[NSBlockOperation main]
-[__NSOperationInternal _start:]
__NSOQSchedule_f
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread2
_pthread_wqthread
start_wqthread

Please, can anyone help?

import * as React from 'react';
import { Text, View, Image, ScrollView, StyleSheet } from 'react-native';
import {
  createDrawerNavigator,
  createAppContainer,
  DrawerItems,
  SafeAreaView,
} from 'react-navigation';



class Home extends React.Component {
  static navigationOptions = {
    title: 'Home',

  };

  render() {
    return (
      <View style={styles.container}>


      </View>
    );
  }
}





const navigator = createDrawerNavigator(
  {
    Home,

  },
  {
    // drawerType: 'back',
    // drawerPosition: 'right',
    // drawerWidth: 200,
    // drawerBackgroundColor: 'orange',
    // contentComponent: CustomDrawerContentComponent
  }
);

export default createAppContainer(navigator) ;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  }
});

3 Answers

0
Masuk Helal Anik On Best Solutions

You have to write this way to work this

const Navigation=createAppContainer(navigator)
export default Navigation;
0
Vishal Dhanotiya On

I think this is a naming convention issue Please rename navigator to Navigator

const Navigator = createDrawerNavigator( { Home, }, 
{ // drawerType: 'back',
 // drawerPosition: 'right', 
// drawerWidth: 200, // drawerBackgroundColor: 'orange',
 // contentComponent: CustomDrawerContentComponent } );

 export default createAppContainer(Navigator) ; 
0
Camille Basbous On

I tried Masuk Helal Anik and Vishal's way today and they both worked, strange...