1喻括、初始化命令蒲拉,導(dǎo)入所有組件模塊:npm install
2甸各、查看當(dāng)前未處于最新版本的組件包:npm outdated
3慌随、更新指定組件包到指定版本:npm install --save react-native-swipe-cards@0.1
npm install --save 包名@版本號
4芬沉、將組件包link到IOS和Android項目中(為IOS和Android添加依賴):react-native link
5、react-native在使用3中的命令更新后阁猜,需要進(jìn)行升級丸逸,然后用4的命令進(jìn)行l(wèi)ink:react-native upgrade
6、添加額外組件:npm install react-native-deprecated-custom-components --save
npm install 包名 --save
問題:
1蹦漠、Exception: undefined is not an object (evaluating '_reactNative.ViewPropTypes.style')
- 升級react-native版本
2椭员、Unable to resolve module AccessibilityInfo from /Users/xuan/Downloads/30-days-of-react-native-development/node_modules/react-native/Libraries/react-native/react-native-implementation.js: Module does not exist in the module map or in these directories:
/Users/xuan/Downloads/30-days-of-react-native-development/node_modules/react-native/node_modules
,? /Users/xuan/Downloads/30-days-of-react-native-development/node_modules
,? /Users/xuan/node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
- 依賴問題,執(zhí)行react-native link命令
3笛园、RCT***隘击,import的問題一般和依賴的版本不一致有關(guān),需要把所有組件升級到最新版本(或者指定版本):
- 首先執(zhí)行npm outdated研铆,查看過期版本埋同,然后查看編譯報錯的類,一般一一對應(yīng)棵红,然后執(zhí)行更新命令npm install --save react-native-swipe-cards@0.1凶赁,將相應(yīng)組件包升級到指定版本,最后最好執(zhí)行react-native upgrade,執(zhí)行完畢后重新執(zhí)行react-native upgrade虱肄,更新IOS和Android的依賴包致板,必要時可能需要重啟項目
4、Exception: undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner')
- 原因是React版本不匹配咏窿,因為除了合適的React-native版本斟或,還需要合適的React版本,執(zhí)行如下命令集嵌,將React更新到指定版本:npm install --save react@16.0.0-alpha.12
5萝挤、Navigator is deprecated and has been removed from this package. It can now be installed
- 原因是版本升級到0.43以上的話,Navigator不能直接從react-native里面獲取了根欧,需要添加額外的包:npm install react-native-deprecated-custom-components --save怜珍;并且跳轉(zhuǎn)到指定的js文件中修改導(dǎo)入路徑為:import {Navigator} from 'react-native-deprecated-custom-components';