Search code examples
javascriptreactjsarraysstringtwitter

modify the input string to look like twitter's tweet


this is how my twitter clone tweet looks like

its very simple and basic

sorry for spacing mistake here I can not mention user and hashtag and create a link for them like original twitter

and I was trying to make it more like original twitter like tweet

enter image description here

How can I make my twitter clone tweet look more like original twitter clone. I want that blue color like mentions and hashtags

Thank you for your solutions


Solution

  • First convert the string to array using string.split() method.

    Then customize the words you want to edit with array.map() method.

    then I used <YourComponent dangerouslySetInnerHTML={{__html: yourStringContainingHTML }} />

    It worked for me.