# 环境版本
"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.csdn.net/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