React Native 已經(jīng)發(fā)布很多天了溯泣,增加了很多有意思的特新
https://github.com/facebook/react-native/releases/tag/v0.19.0-rc
如 react-native 增加了一個(gè) Usage固蛾,如你所見到的一樣待错,有些新的面孔出現(xiàn)。
$ react-native
Usage: react-native <command>
Commands:
- start: starts the webserver
- bundle: builds the javascript bundle for offline use
- unbundle: builds javascript as "unbundle" for offline use
- new-library: generates a native library bridge
- link: Adds a third-party library to your project. Example: react-native link awesome-camera
- android: generates an Android project for your app
- run-android: builds your app and starts it on a connected Android emulator or device
- run-ios: builds your app and starts it on iOS simulator
- upgrade: upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
升級
- 修改 package.json 的版本為0.19.0-rc1,然后執(zhí)行 npm i
"dependencies": {
"react-native": "^0.19.0-rc",
...
}
或者直接安裝
npm install --save react-native@0.19.0-rc
- 執(zhí)行 upgrade
react-native upgrade
如果文件有沖突的,會提示你是否覆蓋
執(zhí)行完畢后,測試下
測試
iOS
react-native run-ios
Android
react-native run-android
問題
不過大部分用戶可能會遇到什么react-deep-force-update的.babelrc的一個(gè)unkonw option充边,那是因?yàn)橐蕾嚨牡谌桨?react-proxy, 目前 master 已經(jīng)修復(fù)了)還在使用老版本的Babel,所以你可以參考如下的方案
https://github.com/facebook/react-native/issues/5393
即在 package.json 的 scripts中增加如下選項(xiàng):
"scripts": {
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc"
}
然后就能正在執(zhí)行了贡避。