I want to parse a string containing jsx
into react-native
Component
Example:
const str1 = "Hi I am default text <Text style={{fontWeight: 'bold'}}>I am bold text</Text>";
Now I want to render it like below:
const App = props => {
return (
<View>
<Text> {str1} </Text>
</View>
);
}
I should note that, the above code works if I change it to:
const str2 = <Text>Hi I am default text <Text style={{fontWeight: 'bold'}}>I am bold text</Text></Text>;
but per my condition str1
can be only string, because I am taking it from TextInput Component
.
Expectation: str1
should be parsed like below:
Hi I am default text I am bold text
What is my goal ?
I want to create a post, within my app, think the post text is:
Hi friends How are you please Like the post.
As you can see Like is bold an italic, so I want to make something like this.