react native项目从创建到运行,以及一些常用命令和可能出现的问题

# 环境版本

"react": "18.2.0",

react-native-cli: 2.0.1

react-native: 0.71.10

Metro v0.73.9

node 16

 

# 我的代码托管地址

https://gitee.com/xiaoshuozi/react-native-simple-frame.git

 

# 代码推送

git add *

git commit -m '首页添加静态列表,detail 页添加分类列表'

git push

 

# 安装 react-native-cli

npm install -g react-native-cli

 

# 创建项目

npx react-native init AwesomeProject6

 

# 运行

yarn android

或者 react-native run-android

或者重启用 react-native start

或者 npm start

 

# 连接手机

adb devices

 

# 调出开发选项

adb shell input keyevent 82

 

# tab 组件

yarn add react-native-tab-navigator

 

# ui 框架

npm install react-native-elements

使用方法

```

import { AirbnbRating } from 'react-native-elements';

<AirbnbRating />

```

 

# 清除项目缓存,可以使用以下命令进行清除:

npm start -- --reset-cache

 

# 报错:could not batcheBridge,make sure your bundle is packsged correctly 解决方法

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

这个报错可以参考:https://blog.youkuaiyun.com/qq_33618456/article/details/75808181

 

# 报错:Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

引入文件了但是没有重新启动,没有加载过来,重新启动就好了

 

# 报错: Unable to resolve module react-native-vector-icons/Ionicons from E:\zMyFile\xuexi\RN\AwesomeProject5\src\routes\index.js: react-native-vector-icons/Ionicons could not be found within the project or in these directories:

缺少模块,安装上重新运行就好了,还不行的话删掉 node-module 重新 npm install

 

# 运行报错:Task:react-native-gesture-handler:compileDebugJavaWithJavac Failed

解决方法:运行:

npm i jetifier

npx jetify

# ctrl + shift + L 锁定某单词统一修改

# 使用 react-native-vector-icons 出现了叉号和问号的情况

如果你在安卓模拟器中运行上面的代码,出现了叉号和问号的情况,可能是因为你没有正确配置 react-native-vector-icons 库。你需要在 android/app/build.gradle 文件中添加以下代码:

```

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

```

# 安装 redux

npm install redux react-redux

 

# form 表单

npm install formik react-native-paper

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

几个高兴

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值