Show mix image from url and text in one view react

2020-07-13 07:07发布

问题:

I have a problem and don't know how to fix it. I have a message like this:

This is my message:tongue_out::wink:dsdangrydsangryhoanghamobile.comdsd:wink:this is emoji and more text....

It's will be show like an image below with :wink: , :tongue_out: and the others emoji is an image from link: https://filev4.subiz.com/wink.png. All is an string and now i have to parse emoji from url and text to display. I don't know how many text and emoji contain, and how to display all in one view in react-native. Now, i really need some help, thank very much.

回答1:

  1. Slice the message to TEMP array, like this ['This is my message',':tongue_out:',':wink:']
  2. With TEMP, detect element :abc: for image, then you can loop and display Text and Image inline, like inline-image or workaround
  3. The Emoji is the remote image so you have to cache it for fast display. You can use FastImage