How can I insert a line break into a component in React Native?

前端 未结 24 1905
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 18:04

I want to insert a new line (like \\r\\n,
) in a Text component in React Native.

If I have:



Hi~
this
24条回答
  •  天命终不由人
    2020-11-28 18:37

    https://stackoverflow.com/a/44845810/10480776 @Edison D'souza's answer was exactly what I was looking for. However, it was only replacing the first occurrence of the string. Here was my solution to handling multiple
    tags:

    
        {shortDescription.split("
    ").join("\n")}

    Sorry, I couldn't comment on his post due to the reputation score limitation.

提交回复
热议问题