I have a string like it
let str = "You would get items\nwhich value about **$50**\nif you **pre-booked** it!"
I would like to replace \n
to<br/>
and I achieved it with the below code.
str.split('\n').map((line)=>(<span>{line}<br/></span>)
What I achieved
<span>You would get items<br/></span>
<span>which value about $50<br/></span>
<span>if you pre-booked it!</span>
And now, I want to emphasize some words like this.
What I expect
<span>You would get items<br/></span>
<span>which value about <b>$50</b><span>
<span>if you <b>pre-booked</b> it!</span>
I want to use like the below it.
const TextFormat = ({text}) => (
<React.Fragment>
{
text.split('\n').map((line, i) => (<span key={i}>{line}<br/></span>)
}
</React.Fragment>
)