Relay: [babel] How to use react-native-stage-0/decorator-support with Relay.

Created on 16 Oct 2016  路  2Comments  路  Source: facebook/relay

I am trying to use react-native + relay + ex-navigation, and having a problem with babel compilation.

ex-navigation uses (babel-preset-react-native-stage-0)[https://github.com/skevy/babel-preset-react-native-stage-0] so I have to add it to my .babelrc

Here's how my .babelrc looks like with ex-navigation:

{
  "passPerPreset": true,
  "presets": [
    {"plugins": ["./plugins/babelRelayPlugin"]},
    "react-native-stage-0/decorator-support"
  ]
}

It was working well when I was using the following config before using ex-navigation:

{
  "passPerPreset": true,
  "presets": [
    {"plugins": ["./plugins/babelRelayPlugin"]},
    "react-native"
  ]
}

Now that it uses react-native-stage-0/decorator-support instead of react-native, it errors with the following error message:

SyntaxError app/node_modules/@exponent/ex-navigation/src/ExNavigationStack.js: Method has decorators, put the decorator plugin before the classes one.

Any thoughts on what this is about?

Most helpful comment

{
  "presets": [
    "react-native-stage-0/decorator-support"
  ],
  "plugins": [
    [ "./src/relay/babelRelayPlugin" ]
  ]
}

drop passPerPreset.

All 2 comments

{
  "presets": [
    "react-native-stage-0/decorator-support"
  ],
  "plugins": [
    [ "./src/relay/babelRelayPlugin" ]
  ]
}

drop passPerPreset.

Thanks! It worked for me.
I removed extra parenthesis for relay plugin, too.
Here's my final babelrc that works:

{
      "presets": [
        "react-native-stage-0/decorator-support"
      ],
      "plugins": [
        "./plugins/babelRelayPlugin"
      ]
    }
Was this page helpful?
0 / 5 - 0 ratings