react-native-svg Unable to resolve "./elements/ForeignObject" from "node_modules/react-native-svg/src/ReactNativeSVG.ts

Currently using SDK 36, tested on Android.

I can’t seem to use react-native-svg. I get the error Unable to resolve "./elements/ForeignObject" from "node_modules/react-native-svg/src/ReactNativeSVG.ts.

My code is really simple, taken straight from the example here.

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

export default class SvgExample extends React.Component {
  render() {
    return (
      <View
        style={[
          StyleSheet.absoluteFill,
          { alignItems: 'center', justifyContent: 'center' },
        ]}>
        <Svg height="50%" width="50%" viewBox="0 0 100 100">
          <Circle
            cx="50"
            cy="50"
            r="45"
            stroke="blue"
            strokeWidth="2.5"
            fill="green"
          />
          <Rect
            x="15"
            y="15"
            width="70"
            height="70"
            stroke="red"
            strokeWidth="2"
            fill="yellow"
          />
        </Svg>
      </View>
    );
  }
}

I’ve also tried importing it like this:

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

As suggested on react-native-svg’s github, but it didn’t change anything.

Found this solution on github, but expo start --clear didn’t work. And I don’t understand what this solution entails.

How do I fix this?

Tested on iOS same error.I try this.
Then I upgrade to ^12.0.3 also got This error and the solution "downgrading react-native-svg to "9.13.3". It does not make sense!

For me worked downgrading

    "react-native-chart-kit": "^2.6.0",
    "react-native-svg": "^9.13.3",
rm -rf node_modules
rm package-lock.json
expo start -c

Also uninstall expo in simulator

I have absolutely no idea what happened but it wasn’t working two days ago, it wasn’t working yesterday and suddenly today it’s working.

I haven’t changed anything.