2019-12-04
1、RN升級到0.61.0版本,項目依賴的第三方庫可能也要隨之升級,因爲Android版本更新後,舊版本的第三庫使用的可能是老舊的API,與新版本不兼容,因此需要升級。
2、新版react-native移除了部分老舊的組件,部分API也會隨之更新。舊版本的react-native若使用這些組件或者API就會報錯。
3、第三方庫有兼容性問題或者報錯,可以到對應庫github上面的issues去查找解決方案。
(1)查看github的issues,搜索關鍵字看有沒有類似的問題,可能會找到解決方案。
(2)查看release,看看第三方庫的更新日誌,尋找一個兼容性好的新版本。
RN升級到0.61.0版本後,組件和第三方庫相關的問題(導致APP報錯不能正常運行)
1、添加@react-native-community/netinfo。(網絡狀態)
新版本react-native剔除了NetInfo模塊,把它放到了@react-native-community/netinfo庫當中,引用NetInfo模塊須從@react-native-community/netinfo庫獲取。
https://github.com/react-native-community/react-native-netinfo
2、react-native-scrollable-tab-view
錯誤信息:Android: Invariant Violation requireNativeComponent: "RNCViewPager" was ton found in the UIManager。
解決辦法:
yarn add @react-native-community/viewpager
react-native link @react-native-community/viewpager
3、WebView組件(導致APP報錯不能正常運行)
錯誤信息:Invariant Violation: WebView has been removed from React Native. It can now be installed and imported from 'react-native-webview' instead of 'react-native'。
錯誤原因:新版本react-native剔除了WebView組件,把它放到了react-native-webview庫當中。引用WebView組件須從react-native-webview庫獲取。