xxxxxxxxxx
const text = 'Tommy Vercetti \n Carl Johnson'
// Inside our render function we want to loop through the string:
let newText = text.split('\n').map(i => {
return <p>{i}</p>
});
// The result :
Tommy Vercetti
Carl Johnson
xxxxxxxxxx
const myString = "This is the first line.\nThis is the second line.";
const App = () => {
return (
<div>
<p>{myString}</p>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));