I am currently working on a app where user can mention their friends.
If user inputs something with @user1 I will get user1's image and display on the message.
Lets say if user types Hey @user1, whats up ? then in place of @user1, his thumbnail should be displayed.
User's thumbnail is in its username path somewhere like user1.jpg
function getTextWithThumb(str) {
var withThumb = str.replace(userCheckRegex, `<Image source=require("../" + ${$&} + ".jpg") />`)
return withThumb
}
Here I am stucked at returning Image Component along with text dynamically out of react component.
<Text>{getTextWithThumb("Hey @user1, whats up ?")}</Text>
Which should give something like,
<Text> Hey <Image source="some_source" />, whats up ? </Text>
Is there any way I can achieve this ? Really need help here.
Thank you
<Image />component, not a string literal wrapped in back ticksgetTextWithThumbis it a component method? If so what component is it on? Can you post the code?