I'd like to do something like the following (but with str actually determined dynamically):
let str = "I like to drive my car fast";
str = str.replace("car", "<Text style={styles.red}>red car</Text>");
return (
<Text>{str}</Text>
);
Is there anyway to insert JSX into other JSX using strings?
edit: and I'd like to avoid doing it via determining the index position of 'car' and then splitting it all up into parts and reconstructing by concatenating JSX fragments.
edit2: Just to be a bit more clear, what I want to do is dynamically read a string like "I like #pizza very much", identify the tag, and output the string with #pizza in blue (i.e. like a tag on twitter etc).