React-native-svg: ForeignObject not working on ios/android

Created on 23 Jan 2020  路  3Comments  路  Source: react-native-svg/react-native-svg

Hello,

I'm trying to use the ForeignObject component in my expo project but it returns me this error below
I wanted to use this component in order to display non-svg components like Text/TextInput in svg tags.

React native info output:

image

Library version: [email protected]

Sample code

here is the code i'm trying to run :

http://pastebin.fr/60472

Is it possible to check why this error is happening ?
Thank you very much for your help

question

Most helpful comment

I got it... Somehow instead of importing it this way:
import { Circle, ForeignObject } from 'react-native-svg';

I need to import it this way:
import ForeignObject, { Circle } from 'react-native-svg';

All 3 comments

Not sure if expo has any of the versions including ForeignObject yet.

I have the exact same issue with Expo.
@msand

Not sure if expo has any of the versions including ForeignObject yet.

What do you mean by that? The react-native-svg version? I just removed my npm cache, installed react-native-svg again and I can see that in my and the nodes_module's package.json file of the library the version is 12.1.0. But I still get the same error as @guiguithub . Also, the ForeignObject.js file exists in the module > elements folder... Not sure what to do...

I got it... Somehow instead of importing it this way:
import { Circle, ForeignObject } from 'react-native-svg';

I need to import it this way:
import ForeignObject, { Circle } from 'react-native-svg';

Was this page helpful?
0 / 5 - 0 ratings