react-native-svg
react-native-svg copied to clipboard
fetchText method error : TypeError: Cannot read property 'prototype' of undefined when trying to call svg from uri
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-svg/src/xml.tsx b/node_modules/react-native-svg/src/xml.tsx
index c6f1799..cf09c94 100644
--- a/node_modules/react-native-svg/src/xml.tsx
+++ b/node_modules/react-native-svg/src/xml.tsx
@@ -28,6 +28,8 @@ import ClipPath from './elements/ClipPath';
import Pattern from './elements/Pattern';
import Mask from './elements/Mask';
import Marker from './elements/Marker';
+import axios from 'axios';
+
export const tags: { [tag: string]: ComponentType } = {
svg: Svg,
@@ -125,11 +127,10 @@ export function SvgXml(props: XmlProps) {
}
export async function fetchText(uri: string) {
- const response = await fetch(uri);
- if (response.ok) {
- return await response.text();
- }
+ const response = await axios.get(uri)
+ if(response.status = 200) return await response.data;
throw new Error(`Fetching ${uri} failed with status ${response.status}`);
+
}
export function SvgUri(props: UriProps) {
This issue body was partially generated by patch-package.