Jav*_*ier 7 react-native react-native-gifted-chat react-native-safe-area-view
当尝试从“react-native-gifted-chat”导入和使用 GiftedChat 组件时,我收到此错误:
Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider, js engine: hermes
我已经尝试过这里列出的几件事。人们似乎对与“react-native-safe-area-context”相关的其他软件包也有类似的问题。
我没有使用 expo,但我使用的是 React Native CLI。
在我看来,问题出在“react-native-gifted-chat”上。
细节:
如果有人有任何想法或见解,我将不胜感激。如果我找到解决方案,我会将其作为评论发布。
Jav*_*ier 21
根据这篇文章,该错误意味着相同的扩展被安装了多次。
\n检查了使用“react-native-safe-area-view”的位置
\nnpm list react-native-safe-area-context
结果:
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/bottom-tabs@6.3.1\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/elements@1.3.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@3.1.9 deduped\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@3.1.9 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/stack@6.2.1\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@3.1.9 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-native-gifted-chat@1.0.0\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@3.1.9\nRun Code Online (Sandbox Code Playgroud)\n似乎有天赋的聊天正在引入 4.2.4 和 3.1.9
\n将“react-native-safe-area-context”更新到最新版本(4.2.5)
\n跑npm dedupe
“react-native-gifted-chat”似乎仍在引入两个版本
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/bottom-tabs@6.3.1\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/elements@1.3.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.5 deduped\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.5 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/stack@6.2.1\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.5 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-native-gifted-chat@1.0.0\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.5\nRun Code Online (Sandbox Code Playgroud)\n这看起来很奇怪,所以我检查了 node_modules 中的包本身node_modules/node_modules/react-native-gifted-chat/package.json,发现依赖项专门请求 4.2.4
"dependencies": {\n "@expo/react-native-action-sheet": "3.13.0",\n "dayjs": "1.8.26",\n "prop-types": "15.7.2",\n "react-native-communications": "2.2.1",\n "react-native-iphone-x-helper": "1.3.1",\n "react-native-lightbox-v2": "0.9.0",\n "react-native-parsed-text": "0.0.22",\n --> "react-native-safe-area-context": "4.2.4", <--\n "react-native-typing-animation": "0.1.7",\n "use-memo-one": "1.1.1",\n "uuid": "3.4.0"\n },\nRun Code Online (Sandbox Code Playgroud)\n他们不要求 ^4.2.4,而是特别要求版本 4.2.4
\n附注:\n ^字符定义了可接受的版本范围,其中包括从指定版本到(但不包括)下一个版本的所有补丁和次要版本。所以“^1.2.3”可以近似展开为“">=1.2.3 <2.0.0”。
\n这是什么意思?
\n我安装了“react-native-gifted-chat”所需的版本,它将与所有其他依赖项一起使用,然后检查它是否最终被重复数据删除。
\nnpm install react-native-safe-area-context@4.2.4
npm list react-native-safe-area-context
终于删除了重复数据
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/bottom-tabs@6.3.1\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/elements@1.3.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4 deduped\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-navigation/stack@6.2.1\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-native-gifted-chat@1.0.0\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4 deduped\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react-native-safe-area-context@4.2.4\nRun Code Online (Sandbox Code Playgroud)\n错误已修复。
\n不要忘记重新安装你的 Pod。
\n长话短说
\nnpm install react-native-safe-area-context@4.2.4| 归档时间: |
|
| 查看次数: |
3478 次 |
| 最近记录: |