ReactNative 中的 Mobx 安装失败
Mobx installation in ReactNative fails
在 ReactNative 中安装 Mobx 失败
我关注 this guide
"react-native": "0.61.5"
我通过创建进行安装,但出现
错误
warn 包 babel-plugin-transform-decorators-legacy 已被忽略,因为它包含无效配置。原因:找不到模块 'babel-plugin-transform-decorators-legacy \ package.json'
如何在没有这些错误的情况下在 ReactNative 上安装 Mobx
我找到了一个 great link 帮助我在 React Native 中安装 Mobx
npm install mobx mobx-react --save //to install mobx
And then you have to install babel. The problem that I ran into while installing setting up this project was that I have to install
@babel/plugin-proposal-decorators
@babel-plugin-transform-decorators-legacy.
@babel/plugin-proposal-class-properties
@babel/plugin-transform-flow-strip-types.
npm install @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties @babel/plugin-transform-flow-strip-types --save
然后你必须改变 babel.config.js 如下;
module.exports = {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true}],
["@babel/plugin-proposal-class-properties", { "loose": true}]
]
};
或者,你可以在没有设计器的情况下使用 mobx,然后就不需要了
我喜欢 MobX(比 Redux 更喜欢它),我不得不与 Babel 插件的整个挑战作斗争才能让装饰器工作。最后我决定停止使用它们,只使用 MobX 自带的 decorate 方法。
在 ReactNative 中安装 Mobx 失败 我关注 this guide
"react-native": "0.61.5"
我通过创建进行安装,但出现
错误warn 包 babel-plugin-transform-decorators-legacy 已被忽略,因为它包含无效配置。原因:找不到模块 'babel-plugin-transform-decorators-legacy \ package.json'
如何在没有这些错误的情况下在 ReactNative 上安装 Mobx
我找到了一个 great link 帮助我在 React Native 中安装 Mobx
npm install mobx mobx-react --save //to install mobx
And then you have to install babel. The problem that I ran into while installing setting up this project was that I have to install
@babel/plugin-proposal-decorators
@babel-plugin-transform-decorators-legacy.
@babel/plugin-proposal-class-properties
@babel/plugin-transform-flow-strip-types.
npm install @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties @babel/plugin-transform-flow-strip-types --save
然后你必须改变 babel.config.js 如下;
module.exports = {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true}],
["@babel/plugin-proposal-class-properties", { "loose": true}]
]
};
或者,你可以在没有设计器的情况下使用 mobx,然后就不需要了
我喜欢 MobX(比 Redux 更喜欢它),我不得不与 Babel 插件的整个挑战作斗争才能让装饰器工作。最后我决定停止使用它们,只使用 MobX 自带的 decorate 方法。