My input is
const text = 'Hello @kevin12 How are you?'
How I render it
<span>{text}</span>
How I want to render it
<span>Hello <em>@kevin12</em> How are you?</span>
My parsing function (incomplete)
const parseText = value => {
const mention = value.substring(value.lastIndexOf('@')+1)
const words = value.split(mention)
return words.map(word => word === mention ? React.createElement('em', {}, word) : word)
}
...
<span>{parseText(text)}</span>
Please help me complete this rendering function.