react-native – 如何在React Native 0.57中使用MobX和装饰器?
发布时间:2020-12-15 05:04:41 所属栏目:百科 来源:网络整理
导读:我在反应原生应用程序中使用MobX. 升级到0.56后,我使用了以下答案中提供的解决方案:https://stackoverflow.com/a/51234815/5597641 但是,它不再适用于0.57.关于.babelrc配置的任何想法都会有所帮助…… 过了一段时间,我找到了使MobX与React Native 0.57一起
我在反应原生应用程序中使用MobX.
升级到0.56后,我使用了以下答案中提供的解决方案:https://stackoverflow.com/a/51234815/5597641 但是,它不再适用于0.57.关于.babelrc配置的任何想法都会有所帮助……
过了一段时间,我找到了使MobX与React Native 0.57一起工作的工作配置.问题在于新模块:在0.57中引入的metro-react-native-babel-preset.我们需要使用@ babel / plugin-transform-flow-strip-types插件来克服这个问题……
这是工作的.babelrc配置 { "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}] ] } 和package.json依赖项: "dependencies": { "babel-plugin-transform-flow-strip-types": "^6.22.0","mobx": "^5.5.0","mobx-react": "^5.2.8","mobx-state-tree": "^3.5.0","native-base": "^2.8.1","react": "16.5.0","react-native": "0.57.1",},"devDependencies": { "@babel/plugin-proposal-class-properties": "^7.1.0","@babel/plugin-proposal-decorators": "^7.1.2","babel-jest": "23.6.0","jest": "23.6.0","metro-react-native-babel-preset": "0.48.0","react-test-renderer": "16.5.0" } 安装所需的依赖项后,请按照以下注释https://github.com/facebook/react-native/issues/20150#issue-340235017中的解决方法2进行操作 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |