react replace all line breaks with br

JavaScript
{
    string.split('\n').map((line, i) => (
        <span key={i}>
            {line}
            <br/>
        </span>
    ))
}
Source

Also in JavaScript: