我已经将使用巴别塔7的RN应用程序从0.55.4升级到了0.56.
在0.55.4中,要使用MOBX的decorator ,我使用"babel plugin transform decorators legacy",但与babel 7不兼容...
react 本机版本:0.56.0
有人有解决办法吗?
谢谢
UPDATE:
该应用程序在DEBUG
种配置下工作
package.json
...
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
"@babel/plugin-proposal-decorators": "7.0.0-beta.47"
...
}
.babelrc
{
"presets": [
["react-native"]
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
}
但在RELEASE
xCode崩溃时,出现了以下错误:
babelHelpers.applyDecoratedDescriptor is not a function.
UPDATE 2, WORKING CONFIG:
这是我的工作配置:
package.json
...
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
"@babel/plugin-proposal-decorators": "7.0.0-beta.47",
"@babel/runtime": "7.0.0-beta.47",
"babel-jest": "23.2.0",
"babel-preset-react-native": "5.0.2",
"jest": "23.3.0",
"react-test-renderer": "16.4.1"
}
...
.babelrc
{
"presets": [
["react-native"]
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
}
然后在索引中.js(主应用程序启动文件)我需要导入decorators babel库:
index.js
import applyDecoratedDescriptor from '@babel/runtime/helpers/es6/applyDecoratedDescriptor';
import initializerDefineProperty from '@babel/runtime/helpers/es6/initializerDefineProperty';
Object.assign(babelHelpers, {applyDecoratedDescriptor, initializerDefineProperty});
require('./app.js');
app.js
import {AppRegistry} from 'react-native';
import AppName from './app/index';
AppRegistry.registerComponent(appName, () => AppName);