I want to insert a new line (like \\r\\n,
) in a Text component in React Native.
If I have:
Hi~
this
Another way to insert
between text lines that are defined in an array:
import react, { Fragment } from 'react';
const lines = [
'One line',
'Another line',
];
const textContent =
lines.reduce(items, line, index) => {
if (index > 0) {
items.push(
);
}
items.push({line} );
return items;
}, []);
Then the text can be used as variable:
{textContent}
If not available, Fragment
can be defined this way:
const Fragment = (props) => props.children;