安装相关软件
注意:安装完 node 如果用 npm 安装其他包时进度缓慢可以设置 npm 镜像:
Homebrew
/// Homebrew用来安装mac上面软件工具
ruby - e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Node
brew install node
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
React-Native 集成环境
sudo npm install - g react - native - cli
Xcode:运行 iOS
去 app Store 下载即可
Android Studio:运行 android
下载地址: www.android-studio.org
可选安装
Watchman
监控文件变化
静态的JS类型检查工具(实际开发基本可以忽略)
brew install watchman
Flow
brew install flow
React 开发工具
选择 Atom 作为开发 React-native 编辑器
Atom
下载地址: atom.io
React 调式工具
调式工具我们用 Facebook 开发的:Nuclide
Nuclide
是由 Facebook 提供的基于 atom 的集成开发环境,可用于编写,运行和 调试 React Native 应用,打开 Atom Setting 界面:
点击
Packages
搜索到
Nuclide
点击
install
即可(重启
atom
会自动安装
Nuclide
依赖包)
Atom 开发 React/React-Native 有力插件
atom-react-autocomplete React 代码提示插件
language-babel React 开发核心插件
atom-react-native-style React-native 组件 CSS 样式提示插件
autocomplete-js-import js 包导入路径提示插件
autocomplete-modules React modules 导入提示插件
autocomplete-paths 加载本地文件自动提示路径插件
language-javascript-jsx JavaScript, ES6, ES7, React JSX, Flow 支持插件
react-es6-snippets es6 写 react 语法提示插件
构建 React-Native 项目
个人网站: www.wuhaichao.com github: https://github/netyouli
/// 用reac-native 初始化并且创建名为ProjectName的React-native项目
react-native init ProjectName
/// cd 到ProjectName目录下下面
npm start /// 启动开发服务器
react-native run ios /// 即可运行在ios模拟器上面
react-native run android /// 即可运行在android模拟器上面
来源: https://juejin.im/post/5a531f8af265da3e56615f53