Run custom Babel transform using React-Native

I need to use babel-plugin-transform-decorators-legacyusing React-Native to enable @decorators. How to configure React-Native / Babel to make this possible?

This is related to my previous question on how to get @decorators to work in React-Native: stack overflow

+4
source share
4 answers

Use Babel Utility Presets

Install the official Babel presets for React Native applications :

npm i babel-preset-react-native --save-dev

Change your .babelrc:

{
  "presets": ["react-native"]
}

RN Priority v21.0: Extend source .babelrc from native-native

node_modules, .babelrc.

, .

{
    "extends": "react-native/packager/react-packager/.babelrc",
}
+5

, .babelrc node_modules/react-native/packager/react-packager/.babelrc

@decorators , , .babelrc, node_modules .

+3

2016 .babelrc index.ios.js index.android.js, :

{
  "plugins": [
    "transform-decorators"
  ]
}
+1

You should add it to your .babelrc in your active folder in your node_modules folder.

This file: react native / packer / react-packer / .babelrc.

Place it in front of the properties of the syntax class.

You will also need .babelrc at the root level, as shown below.

    {
      "plugins": [
        "transform-decorators"
      ]
    }
+1
source

Source: https://habr.com/ru/post/1619909/


All Articles