Reputation: 7985
Mobx installation in ReactNative fails I follow this guide
"react-native": "0.61.5"
I do the installs by creation but I get an error of
warn Package babel-plugin-transform-decorators-legacy has been ignored because it contains invalid configuration. Reason: Cannot find module 'babel-plugin-transform-decorators-legacy \ package.json'
How do I install Mobx on ReactNative without these errors
Upvotes: 2
Views: 371
Reputation: 7985
I found a great link that helped me install Mobx in react native
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
And then you have to change babel.config.js like below;
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}]
]
};
Alternatively, you can use mobx without designers and then all that is not needed
As shown in the mobx documentation
Upvotes: 4
Reputation: 53
I love MobX (prefer it way more over Redux), Ive had to battle the whole gauntlet of Babel plugins to get decorators to work. Finally i decided to stop using them and just use the decorate method that comes with MobX.
Upvotes: 1