React-native-router-flux: SyntaxError /node_modules/react-native-router-flux/src/navigationStore: Unexpected token (18:0)

Created on 26 Jun 2017  路  16Comments  路  Source: aksonov/react-native-router-flux

Version

  • react-native-router-flux v4.0.0-alpha.4
  • react-native v0.41.x
  • typescript 2.3.2

Details

I do the straightforward route creation:

<View style={{flex: 1, backgroundColor: Layout.backgroundColor.white}}>
        <View style={styles.app}>
          <Router sceneStyle={{backgroundColor:'#fff'}}>
            <Scene key="root">
              <Scene key="tour" initial={initialRouteName === 'tour'} component={Tour}/>
              <Scene key="signup" initial={initialRouteName === 'signup'} component={SignUp}/>
              <Scene key="register" component={Register}/>
              <Scene key="login" component={Login}/>
              <Scene key="main" tabs={true} initial={initialRouteName === 'main'}>
                <Scene key="feed" component={Feed} icon={selected => (<Image source={selected ? iconFeed : iconFeedGray}/>)
                  }></Scene>
                <Scene key="map" component={View} icon={selected => (<Image source={selected ? iconMap : iconMapGray}/>)
                  }></Scene>
                <Scene key="camera" component={Scan} icon={selected => (<Image source={selected ? iconCamera : iconCameraGray}/>)
                  }></Scene>
                <Scene key="search" component={View} icon={selected => (<Image source={selected ? iconFind : iconFindGray}/>)
                  }></Scene>
                <Scene key="profile" component={Profile} icon={selected => (<Image source={selected ? iconProfile : iconProfileGray}/>)
                  }></Scene>
              </Scene>
            </Scene>
          </Router>
        </View>
      </View>

And got the error dictated in the title. Is this dependency problem?
Thank you very much

Most helpful comment

@thanhtr, after my "solving" method I had another issue :( So I downgraded my version to 3.40.1 and now I don't have any problem.t

All 16 comments

I had the same problem, if you go to navigationStore you can see @autobind, that's the problem, I solved the issue with this:
https://moduscreate.com/using-es2016-decorators-in-react-native/
But I'm not sure if this gonna work to you because I don't use Typescript!

+1

+1

@lattuguini Thank you for your suggestion. I'd try it out now and let you know the result :)

After clear the node_modules, installing babel-plugin-transform-decorators-legacy and declare as plugin in .babelrc as instructed from the site you suggested I got into this error. So I don't know if it is still result of the fact that I use typescript.

screen shot 2017-06-26 at 14 07 35

+1 Struggling with this issue..

I will downgrade stabler version of router flux. This one seems to be really alpha and maybe it's not the time yet.

Yep, same here @thanhtr. I just realized it. Downgrade to 3.39.1 should fixed this issue.

@thanhtr I've gotten "Cannot read property 'style' of undefined for this module before but for a different issue. I was able to correct that issue with react-native-git-upgrade.

I've yet to solve this thread's issue for my project. I'd rather not downgrade... will touch base when I get it resolved on my end.

I'm curious why

  • v4-alpha version was published to npm from a branch
  • the latest master is 3.40.1
  • the latest release on github is 3.39.1.

The v4-alpha is clearly not ready yet. The release process seems a bit messy.

@thanhtr, after my "solving" method I had another issue :( So I downgraded my version to 3.40.1 and now I don't have any problem.t

Sorry, but v4.0.0 is ALPHA and definitely is not ready for production. As I see npm recognize 'alpha' correctly and doesn't install it by default.

@thanhtr You have to add 'decorator' support to your project. Check Example project for .babelrc config.

@thanhtr API for Router is changed - you have to wrap root Scene with Router function, see more details here: https://github.com/aksonov/react-native-router-flux/issues/1595 and Example project.

yarn did install the 4.0.0 alpha by default

@mistenkt Fixed now, thanks.

@thanhtr You may want to try latest v4 beta now, it should not have this error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

kirankalyan5 picture kirankalyan5  路  3Comments

xnog picture xnog  路  3Comments

YouYII picture YouYII  路  3Comments

tonypeng picture tonypeng  路  3Comments