RN-Navigation

本文记录了在React Native项目中整合Navigation模块所遇到的挑战,包括版本不兼容、端口占用和react-native-gesture-handler的链接问题。通过解决一系列常见错误,如'null is not an object'和'Module不存在',最终成功导入并运行Navigation模块。开发流程涉及react-navigation和react-native-gesture-handler两个库,其中后者需要手动link。遵循错误提示进行清理缓存和重置,完成Navigation的初步设置。
摘要由CSDN通过智能技术生成

在React Native 项目中导入 Navigation模块
这个过程的学习费了差不多一天的工作量;人间地狱
其实也简单,就是重复冒出慕名奇妙的错误让我抓狂
先是 yarn add 后react-native版本不兼容,然后升级版本,有出现端口占用,清除占用端口,然后就是react-native-gesture-handler这个JB玩意在作怪。
期间出现几个RN例常错误:
1,null is not an object (evaluating ‘_RNGestureHandlerModule.default.Direction’)
2,Module react-native-gesture-handler does not exist in the Haste module map

**下面是开发流程
Navigation模块依赖两个库:
react-navigation
react-native-gesture-handler
第一个是导航管理器,类似于iOS的UINavigationController,第二个是滑动手势,管理手势对页面跳转的控制
导入:
yarn add react-navigation
yarn add react-native-gesture-handler
react-native link react-native-gesture-handler
这个库不知道为何需要link一下,因为按照正常流程走,最后报错:
Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module react-native-gesture-handler from /Users/gzkp/project/RNtest/node_modules/@react-navigation/native/src/Scrollables.js: Module react-native-gesture-handler does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*. (null))

然后仔细地按照报错提示走完流程,终于是运行起来了

接着进入navigaiton的正常开发联系

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值