Wednesday, May 15, 2024
89
rated 0 times [  91] [ 2]  / answers: 1 / hits: 17970  / 5 Years ago, wed, february 20, 2019, 12:00:00

I'm developing an app where at some point app receives a string from Facebook Graph API.



String looks like that:



Some text some text, some text.nnMore text and morennAnd little bit more.


How can I replace nn with line break what actually works in code?



I know how to replace this with something:



var ret = stringToReplace.replace('nn','<br />');


But how can i replace it with working line break. I have tried to replace with 'n' 'rn'. Every replacement just acts like usual text. For example:



Some text some text, some text.<br />More text and more<br />And little bit more

More From » react-native

 Answers
12

I test the following code and it works. You should just wrap your text in a <Text> component.



export default class App extends React.Component {
text = Some text some text, some text.nnMore text and morennAnd little bit more

render() {
return (
<View style={styles.container}>
<Text>
{this.text}
</Text>
</View>
);
}
}


The result of this code is like this:
enter


[#52565] Thursday, February 14, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kiarra

Total Points: 202
Total Questions: 111
Total Answers: 109

Location: Sudan
Member since Mon, May 31, 2021
3 Years ago
;