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?