csb00
csb00

Reputation: 1155

(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)

;

Upvotes: 7

Views: 10059

Answers (3)

Tobias Lins
Tobias Lins

Reputation: 2651

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";

Upvotes: 15

NAFAI HADDI
NAFAI HADDI

Reputation: 49

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'

Upvotes: 3

cherucole
cherucole

Reputation: 678

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

import { createStackNavigator } from "react-navigation-stack";
import { createAppContainer } from "react-navigation";

Upvotes: 17

Related Questions