I have a string that is passed through props. It may consist of several sentences. Can I implement splitting this line inside one tag? Maybe through replace ? The end always – (.). I`m using React
const name = "It is just text 1. It is just text 2. It is just text 3."
<p>{name}</p>
I would like to get –
It is just text 1.
It is just text 2.
It is just text 3.
>Solution :
Easiest way to do this is to split the string into an array based on . as the delimeter.
name.split(".").map(p => <p>{p}.</p>);
Assuming you’re using React.