per*_*n66 19 android typescript react-native expo-go
我对标题中提到的错误感到头疼。\n我正在使用react-native-gifted-charts(https://www.npmjs.com/package/react-native-gifted-charts/v/1.0.3)\n图表在 ios 中完美运行,但在 Android 中它不断崩溃并抛出“Invariant Violation: requireNativeComponent: 在 UIManager 中找不到“RNSVGSvgViewAndroid”。”\n首先我认为这是我的代码的问题,因为它之前适用于 Android ,但即使我反转代码,错误仍然存在。\n我正在使用yarn作为包管理器和Expo托管工作流程。\n依赖项如下。
\n"react-native": "0.70.5",\n"react-native-gifted-charts": "^1.2.42",\n"react-native-linear-gradient": "2.6.2",\n"react-native-svg": "12.1.0",\n\nRun Code Online (Sandbox Code Playgroud)\n\xe2\x96\xa0我尝试过的事情
\nimport React, { useState } from "react";\nimport { View, StyleSheet, Text, TouchableOpacity, ScrollView } from "react-native";\nimport type { NativeStackScreenProps } from "@react-navigation/native-stack";\nimport { MainStackParamList } from "../types/navigation";\nimport dayjs from "dayjs";\nimport { BarChart, LineChart, PieChart } from "react-native-gifted-charts";\nimport { useSelector } from "react-redux";\nimport { RootState } from "../store";\n\nexport const StatisticsScreen: React.FC<Props> = () => {\n const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]\n return (\n <BarChart\n data={data}\n />\n );\n};\nRun Code Online (Sandbox Code Playgroud)\nPS我还运行了yarncache clean希望它是缓存但没有帮助......
\n小智 50
我在尝试使用时也遇到了同样的问题react-native-heroicons,需要我安装react-native-svg,但是当我运行时npx expo install react-native-svg,它起作用了。
小智 15
我在使用时遇到错误"react-native-svg": "13.6.0",降级以"react-native-svg": "13.4.0"解决问题。
那么也许您可以尝试升级到该13.4.0版本?
小智 7
Expo 适用于 13.4.0 版本react-native-svg,但react-native-gifted-charts需要 13.6.0。因此,我安装react-native-svg并expo install覆盖嵌套依赖项以使用 13.4.0 版本,还通过添加
"resolutions": {
"react-native-svg": "13.4.0"
}
Run Code Online (Sandbox Code Playgroud)
到我的 package.json。解决了我的问题
小智 -1
SVG渲染需要这个模块
npm install react-native-svg-transformer --save
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22611 次 |
| 最近记录: |