##设置npm镜像
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
(npm search失效,镜像地址修改回默认https://registry.npmjs.org/)
##设置yran镜像
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
##安卓的需要android studio配置
##安装facebook的watchman
brew install watchman
(brew太慢的话可以切换)=>
在~/.bashrc中加入 export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com
##初始化项目 react-native init projectName
模拟器: ios: ⌘⇧+h =主键
fetch问题:
ios9以上加入新特性App Transport Security (ATS),要求app访问网络必须为https
解决办法:修改info.list
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
删除了这一段 -->NSAppTransportSecurity下(不知道为啥加上这一行,运行就白屏,并且不报错)
<key>NSExceptionDomains</key>
<dict>
<key>demo.deepdot.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>localhost</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
引用:https://segmentfault.com/a/1190000002933776
react-native中的 proptype报错
PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.
使用第三方库prop-types代替,用来检查prop的类型是否合规
用法:
import PropTypes from 'prop-types'
/*假装这里有一个名为bilibili的类*/ bilibili.propTypes = { name: PropTypes.string
//bilibili类接受的prop定义限制为string,具体说明查看文档https://facebook.github.io/react/docs/typechecking-with-proptypes.html }
react-native run-ios时报错: react native development, non-minified, hmr disabled 解决办法:(版本问题) yarn remove babel-preset-react-native yarn add babel-preset-react-native@2.1.0
导航组件 React-natvigation
官方地址:https://reactnavigation.org/docs/intro/
相关文章地址:http://blog.csdn.net/u013718120/article/details/72357698
expo:
http://expo.io/--/api/v2/versions/download-android-apk 安卓下载地址
APP图标替换
项目目录/android/app/src/main/res/
mdpi 48 | hdpi 72 | xhdpi 96 | xxhdpi 144
安卓APK打包:
http://reactnative.cn/docs/0.49/signed-apk-android.html#content
http://www.jianshu.com/p/1380d4c8b596