Zin Myo Oo
Zin Myo Oo

Reputation: 11

How to change string to React Native Component?

I have a react native component string.

const str = '<View style={{'width':200, 'height':50, 'backgroundColor':'blue'}}>';

I want to change this string to react native element. I render this string like this.

<Text>{str}</Text>

It is returning only text.

result

Actually, I want the result like this. How to convert the string element to react native component?

expect result

Upvotes: 0

Views: 242

Answers (1)

Abdelaziz El-emary
Abdelaziz El-emary

Reputation: 430

You can use React Native WebView.

<WebView
    originWhitelist={['*']}
    source={{ html: str }}
/>

https://github.com/react-native-webview/react-native-webview

Upvotes: -1

Related Questions