I want to insert a new line (like \r\n, <br />) in a Text component in React Native.
If I have:
<text><br />
Hi~<br >
this is a test message.<br />
</text>
Then React Native renders Hi~ this is a test message.
Is it possible render text to add a new line like so:
Hi~
this is a test message.
You can use
{'\n'}
as line breaks. Hi~ {'\n'} this is a test message.You can use `` like this:
You can also do:
Easier in my opinion, because you don't have to insert stuff within the string; just wrap it once and it keeps all your line-breaks.
Use:
Result:
I cannot test it right now but this should do it:
This worked for me
(react-native 0.41.0)