【问题标题】:Invariant Violation using react-native-svg使用 react-native-svg 的不变违规
【发布时间】:2020-05-31 09:37:09
【问题描述】:

当我尝试使用 react-native-svg 时出现以下错误:

我在我的代码中使用这样的 react-native-svg:

我这样称呼组件

import BarChart from './BarChart'

// ...

我正在使用 react-native-svg : 9.13.3 和 expo : 36 我使用 expo install react-native-svg 安装了 react-native-svg 并且我已经尝试使用重置缓存重新启动..... 请救救我哈哈 祝你有美好的一天!

【问题讨论】:

  • 你解决了吗?我确实有同样的问题。

标签: reactjs react-native react-redux react-native-svg


【解决方案1】:

问题很可能来自您如何导入Svg

根据我找到的文档,如果您使用的是 Expo,那么您需要导入为:

/* Use this if you are using Expo */

import * as Svg from 'react-native-svg';
const { Circle, Rect } = Svg;

代替你的例子:

import Svg, { Circle, Rect } from 'react-native-svg';

参见Usage 部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    • 1970-01-01
    • 2018-10-04
    • 1970-01-01
    • 2019-09-09
    • 2021-02-22
    • 2019-09-13
    相关资源
    最近更新 更多