本月早些时候facebook发布了React Native 0.59,我的感受算是RN的里程碑,主要有:html
详细内容node
核心就是参考RN diff PURGE来手动升级,这也是官方推荐的方式。此外,rn0.59中移除了react-native-git-upgrade
,取而代之的是react-native upgrade
,而react-native upgrade
就是基于RN diff PURGE。react
好比我是从0.55.4到0.59.2 那么就是https://github.com/react-nati...git
而后查看变动(点击Files changed)来手动更改。github
vs code
中,那么能够在releases中下载对应的版本,在本地建立一个git仓库,再用目标版本的文件替换之。cocoaPods: pod install时报错could not find compatible versions for pod "Folly"
,解决方法:Podfile
中添加web
# Third party deps podspec link pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
官方说明npm
babel7
,transform-decorators-legacy
并不适用,使用@babel/plugin-proposal-decorators,同时带上@babel/plugin-proposal-class-properties。继续报错: TypeError: undefined is not an object (evaluating 'props.getItem'): 这个是@babel/plugin-proposal-class-properties
的锅相关issue。若是你不须要这个,直接移除便可。又或者,添加新的babel plugin@babel/plugin-transform-flow-strip-types
而且保证顺序在@babel/plugin-proposal-class-properties
之上。附:本人项目中.babelrc
plugins部分json
"plugins": [ ["@babel/plugin-transform-flow-strip-types"], ["@babel/plugin-proposal-decorators", { "legacy": true }], ["@babel/plugin-proposal-class-properties", { "loose": true }] ]
至此,你的rn项目应该能够跑起来了。一进去你(可能)会发现很是多的Yellow Box Warning
按照提示慢慢去改进吧~react-native
也但愿这篇文章对那些和我同样没有原生经验的小伙伴有所帮助。babel
Thanks for reading