本月早些時候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