Skip to content

RN Web - StackNavigator is not a function #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
reggi opened this issue Feb 21, 2017 · 10 comments
Closed

RN Web - StackNavigator is not a function #423

reggi opened this issue Feb 21, 2017 · 10 comments

Comments

@reggi
Copy link

reggi commented Feb 21, 2017

I'm trying to get this running on react native web.

Uncaught TypeError: (0 , _reactNavigation.StackNavigator) is not a function
    at Object.defineProperty.value (bundle.js:78675)
    at __webpack_require__ (bundle.js:660)
    at fn (bundle.js:84)
    at Object.defineProperty.value (bundle.js:78642)
    at __webpack_require__ (bundle.js:660)
    at fn (bundle.js:84)
    at Object.defineProperty.value (bundle.js:78489)
    at __webpack_require__ (bundle.js:660)
    at fn (bundle.js:84)
    at Object.defineProperty.value (bundle.js:78556)
    at __webpack_require__ (bundle.js:660)
    at fn (bundle.js:84)
    at Object.<anonymous> (bundle.js:36601)
    at __webpack_require__ (bundle.js:660)
    at fn (bundle.js:84)
    at Object.<anonymous> (bundle.js:79861)
    at __webpack_require__ (bundle.js:660)
    at bundle.js:709
    at bundle.js:712

Also what's weird, when I just run the following with babel-node

import RN from 'react-navigation'
console.log(RN.StackNavigator)

I get this error:

/Users/thomasreggi/Desktop/web/ap/node_modules/react-navigation/src/navigators/StackNavigator.js:3
import React from 'react';
^^^^^^
SyntaxError: Unexpected token import

When I check package.json main it uses the src and not the lib version, why is this?

https://github.com/react-community/react-navigation/blob/master/package.json#L5

@reggi
Copy link
Author

reggi commented Feb 21, 2017

@temitope
Copy link

The second error may be due to react-navigation requiring React to be imported first, so the snippet by itself is kissing dependencies.

@temitope
Copy link

Disregard I see you got an error doing just that.

@reggi
Copy link
Author

reggi commented Feb 21, 2017

@temitope Any idea what's going on?

@reggi
Copy link
Author

reggi commented Feb 21, 2017

Seems like the react-navigation.web.js file doesn't contain StackNavigator.

import RNW from 'react-navigation/lib/react-navigation.web.js';
console.log(RNW)
{ createNavigationContainer: [Getter],
  StateUtils: [Getter],
  addNavigationHelpers: [Getter],
  NavigationActions: [Getter],
  createNavigator: [Getter],
  StackRouter: [Getter],
  TabRouter: [Getter],
  withNavigation: [Getter] }

@temitope
Copy link

temitope commented Feb 22, 2017

@reggi Ahh I am just realizing now that it is a totally different core library (in a way)...yeah if anything would be different between native and web I would assume the navigation would be as it is so different in terms of touch/click/back<->forward buttons, but I must say i dont know as I am unfamiliar with the RN4WEB .... seems like is is still in nascent stages and not yet up to support for full react-navigation features (i.e. DrawerNavigator and StackNavigator)....i probably wouldnt use react-navigation with it as of yet, but I am relatively new to the React/ReactNative world myself so maybe someone with deeper familiarity knows how to integrate them better

@satya164
Copy link
Member

satya164 commented Feb 23, 2017

Just import 'react-navigation/lib/react-navigation.js' if you're using react native for web. react-navigation.web.js is for normal websites.

And if you're getting errors in transpiling, configure webpack to transpile node_modules/react-navigation.

@code-by
Copy link

code-by commented Dec 1, 2017

After updating react-native-router-flux from 3 to 4, got this error in RN4W

@geminiyellow
Copy link

yep , i use rnrf 4, and got this error.

@react-navigation react-navigation locked and limited conversation to collaborators May 8, 2018
@brentvatne
Copy link
Member

can someone who would like to see this issue resolved please create a new issue with a reproducible example on https://snack.expo.io or in a github repository, with a minimal amount of superfluous code? (please don't post your entire app, just a small one to reproduce the problem). thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants