React Native 已经发布很多天了,增加了很多有意思的特新
https://github.com/facebook/react-native/releases/tag/v0.19.0-rc
如 react-native 增加了一个 Usage,如你所见到的一样,有些新的面孔出现。
$ 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,然后执行 npm i
"dependencies": {
"react-native": "^0.19.0-rc",
...
}
或者直接安装
npm install --save react-native@0.19.0-rc
- 执行 upgrade
react-native upgrade
如果文件有冲突的,会提示你是否覆盖
执行完毕后,测试下
测试
iOS
react-native run-ios
Android
react-native run-android
问题
不过大部分用户可能会遇到什么react-deep-force-update的.babelrc的一个unkonw option,那是因为依赖的第三方包(react-proxy, 目前 master 已经修复了)还在使用老版本的Babel,所以你可以参考如下的方案
https://github.com/facebook/react-native/issues/5393
即在 package.json 的 scripts中增加如下选项:
"scripts": {
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc"
}
然后就能正在执行了。
网友评论