Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(0 _reactNavigationStack.createAppContainer) is not a function

I am getting the following error: (0 _reactNavigationStack.createAppContainer) is not a function. I got this error after installing react-native-gesture-handler and linking it. However, I check the terminal and there are no error messages appearing. The ios simulator is telling me that it is in App.JS, where I created the navigator, in the line where I have export deafult. I was wondering if anyone can see something I may not be seeing.

This is how I have my navigator set up, which is in the App.js file.

import {
  createStackNavigator,
  createAppContainer
} from 'react-navigation-stack';
import SearchScreen from './src/screens/SearchScreen';

const navigator = createStackNavigator(
  {
    Search: SearchScreen,
  },
  {
    initialRouteName: 'Search',
    defaultNavigationOptions: {
      title: 'Buisness Search',
    },
  },
);

export default createAppContainer(navigator)

;

like image 260
csb00 Avatar asked Sep 14 '19 21:09

csb00


3 Answers

If you are using React v4 and higher the code below should work

import { createStackNavigator } from "react-navigation-stack";
import { createAppContainer } from "react-navigation";
like image 187
cherucole Avatar answered Nov 06 '22 05:11

cherucole


This is because createAppContainer is not exported by react-navigation-stack

You can import it from react-navigation

import { createAppContainer } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
like image 15
Tobias Lins Avatar answered Nov 06 '22 03:11

Tobias Lins


First install the dependencies :

run npm install react-navigation@^3.0.0 
run npm install react-native-gesture-handler

Then import it in your code :

import { createStackNavigator} from "react-navigation-stack"
import { createAppContainer} from 'react-navigation'
like image 3
NAFAI HADDI Avatar answered Nov 06 '22 05:11

NAFAI HADDI