expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

importing NavigationProvider throws undefined is not an object (evaluating PropTypes.shape in NavigationPropTypes.js:30:26) #497

Open shenders13 opened 6 years ago

shenders13 commented 6 years ago

Hi there!

Running into this issue when doing:

import {
  NavigationProvider,
  StackNavigation,
  createRouter
} from '@expo/ex-navigation';
screen shot 2017-11-05 at 2 06 46 pm

Here is my App.js

import React from 'react';
import { AppRegistry } from 'react-native';

import Expo from 'expo';

import {
  NavigationProvider,
  StackNavigation,
  createRouter
} from '@expo/ex-navigation';

import Home from './views/landing/Home';

const Router = createRouter(() => ({
  home: () => Home,
}));

class App extends React.Component {
  render() {
    return (
      <NavigationProvider router={Router}>
        <StackNavigation initialRoute={Router.getRoute('home')} />
      </NavigationProvider>
    );
  }
}

AppRegistry.registerComponent('Dusato', ()=> App);

This is my package.json:

{
  "name": "dusato",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.6.0",
    "jest-expo": "^22.0.0",
    "react-test-renderer": "16.0.0-beta.5"
  },
  "presets": [
    "react-native-stage-0/decorator-support"
  ],
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/ex-navigation": "^2.11.2",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "expo": "^22.0.2",
    "react": "16.0.0-beta.5",
    "react-native": "^0.49.5",
    "react-native-elements": "^0.18.0",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0"
  }
}

Would be super grateful for any insight!

Sam

sibelius commented 6 years ago

this is happening on 4.0.0

the master version is correct

mattcleary55 commented 6 years ago

I'm getting the same issue. Is there any way around this?

sibelius commented 6 years ago

use 3.1.0

mattcleary55 commented 6 years ago

Thanks!

femiveys commented 6 years ago

So does this mean version 4.0.0 is broken and should not be used?

rahulbhankar786 commented 6 years ago

@sibelius same issue with 3.1.0. please help me. "dependencies": { "@expo/ex-navigation": "3.1.0", "babel-preset-react-native-stage-0": "^1.0.1", "react": "16.0.0", "react-native": "0.50.4", "react-native-vector-icons": "^4.0.1", "react-navigation": "^1.0.0-beta.21" },

elie222 commented 6 years ago

@femiveys there doesn't seem to be a 4.0.0 of this package. latest version is 3.1.0: https://github.com/expo/ex-navigation/commit/98b1c013f06db67d0019f4191388803b28af2719

elie222 commented 6 years ago

@rahulbhankar786 3.1.0 should fix this specific issue. Check you really are on that version and it's the exact same error as displayed here.

rahulbhankar786 commented 6 years ago

@elie222 thanks. have resolved this problem.

rpereira commented 6 years ago

@elie222 @rahulbhankar786 actually, there is a 4.0.0 version of this package published on npm. This version adds iPhone X support: https://www.npmjs.com/package/@expo/ex-navigation

I have the exact same problem that @shenders13 has posted.

What I find weird is that using the following deps on a brand new project, it works without any friction:

        "dependencies": {
                "@expo/ex-navigation": "4.0.0",
                "react": "16.0.0-alpha.12",
                "react-native": "0.47.2"
        },