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

前端 未结 24 1879
佛祖请我去吃肉
佛祖请我去吃肉 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:50

    Why work so hard? it's 2020, create a component to handle this type of issues

        export class AppTextMultiLine extends React.PureComponent {
        render() {
        const textArray = this.props.value.split('\n');
    return (
            
                {textArray.map((value) => {
                   return {value};
                })}
            
        )
    }}
    

提交回复
热议问题