Naryc
Naryc

Reputation: 211

Is there anyway to embed image in <Text> in react-native

Someone may want to implement a richtext edit or richtext view. In html we can do it with inline image tag, but react-native Text can only nest Text in it.

Upvotes: 7

Views: 9395

Answers (2)

Ricky Sahu
Ricky Sahu

Reputation: 24319

Here's a workaround that'll preserve styles

<View style={{flexDirection:'row', flexWrap:'wrap'}}>
    <Image
        style={styles.img}
        source={{uri: imageLink}} />
    <Text>
        {"sweet, this works"}
    </Text>
</View>

Upvotes: 9

John Shammas
John Shammas

Reputation: 2715

This was already added to React Native back in 0.16-rc. Update your React Native version and see examples here:

https://github.com/facebook/react-native/commit/a0268a7bfc8000b5297d2b50f81e000d1f479c76

Upvotes: 3

Related Questions