Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchText method error : TypeError: Cannot read property 'prototype' of undefined when trying to call svg from uri #2256

Open
YassineOujaa77 opened this issue Apr 7, 2024 · 0 comments

Comments

@YassineOujaa77
Copy link

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-svg@13.4.0 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant