1、yarn global add create-react-native-app   //全局安装
2、create-react-native-app 项目名称
3、yarn add typescript tslint -D
4、yarn add @types/react @types/react-native @types/react-dom -D
5、yarn add concurrently rimraf -D
6、yarn add ts-jest @types/jest @types/react-test-renderer -D
7、tsc --init

 8、tsconfig.json

 

{
"compilerOptions": {
"module":"es2015",
"target": "es2015",
"jsx": "react",
"rootDir": "src",
"outDir": "build",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"sourceMap": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"allowJs": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"skipLibCheck": true,
"moduleResolution":"Node"
},
"filesGlob": [
"typings/index.d.ts",
"src/**/*.ts",
"src/**/*.tsx",
"node_modules/typescript/lib/lib.es6.d.ts"
],
"types": [
"react",
"react-dom",
"react-native"
],
"exclude":[
"build",
"node_modules",
"jest.config.js",
"App.js" ],
"compileOnSave": false
}

9yarn add react-native-scripts

10package.json

"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js",
"lint": "tslint src/**/*.ts",
"tsc": "tsc",
"clean": "rimraf build",
"build": "yarn run clean && yarn run tsc --",
"watch": "yarn run build -- -w",
"watchAndRunAndroid": "concurrently \"yarn run watch\" \"yarn run android\"",
"buildRunAndroid": "yarn run build && yarn run watchAndRunAndroid ",
"watchAndRunIOS": "concurrently \"yarn run watch\" \"yarn run ios\"",
"buildRunIOS": "yarn run build && yarn run watchAndRunIOS ",
"watchAndStart": "concurrently \"yarn run watch\" \"yarn run start\"",
"buildAndStart": "yarn run build && yarn run watchAndStart "
}

11package.json

"main":"./node_modules/react-native-scripts/build/bin/crna-entry.js"

12App.js

import App from './build/App';
export default App;

13src -> App.tsx

/* jshint esversion: 6 */
import React, { Component } from "react"
import { View, Text } from "react-native" export default class App extends Component {
render() {
return(
<View>
<Text>hello world</Text>
</View>
)
}
}

14、将babel.config.js移动到src的目录中

 

最新文章

  1. JS 的事件委托机制
  2. C#-数据库访问技术 ado.net——创建 数据库连接类 与 数据库操作方法 以及简单的数据的添加、删除、修改、查看
  3. Linux下编译安装PCRE库
  4. GPUImage相关(转)
  5. 跟我一起学WCF(13)——WCF系列总结
  6. 20145211 《Java程序设计》第2周学习总结——桃花依旧笑春风
  7. 命令提示符CMD远程连接Mysql学习笔记
  8. ongl三种符号的使用
  9. java基础02 数据类型转
  10. Django REST framework+Vue 打造生鲜超市(九)
  11. Spark调度模式-FIFO和FAIR
  12. linux中普通的文件查看操作(cat、more、less、head、tail)
  13. Python:tesserocr 在 windows 下的安装及简单使用
  14. Hadoop集群测试wordcount程序
  15. Gulp入门及简单使用
  16. If you did this already, delete the swap file &quot;.git/.MERGE_MSG.swp&quot;
  17. redis连接错误处理方案分享
  18. XMPP用户登录
  19. miRNA几大常用的数据库
  20. C/C++语言中变量作用域:局部变量,全局变量,文件级变量

热门文章

  1. 题解 UVa10791
  2. 优雅关闭web服务的方式
  3. BZOJ 4197: [Noi2015]寿司晚宴 状压dp+质因数分解
  4. 关于System.AccessViolationException异常
  5. Ps回调函数.拦截驱动模块原理+实现.
  6. c++ 获取字符串中最长的回文子串
  7. kms windows激活
  8. tomcat启动慢的解决办法
  9. 【转】Android系统中Fastboot和Recovery所扮演的角色。
  10. Nacos学习