I'm trying to send following code to a child component in React js:
{
carPhoto: "../../images/small-logo.jpg",
make: "Mercedes",
price: "€20000",
desc: "Vivamus gravida magna massa in cursus mi"
}
Now I'm trying to split desc in two lines. I tried with \n, \r, \r\n
desc: "Vivamus gravida magna<br /> massa in cursus mi"
desc: "Vivamus gravida magna\nmassa in cursus mi"
desc: "Vivamus gravida magna\r\nmassa in cursus mi"
But nothing worked. Any advice?
<span>
Example #1: <br /> newline
</span>
<span style={{ whiteSpace: 'pre-wrap' }}>
{"Example #2: \r new line or \u000A new line"}
</span>
{/* do not forget add style { white-space: pre-wrap } */}
<Example3 text={"Example #2: \r new line or \u000A new line"} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With