Hello Friends 👋,
Welcome To Infinitbility! ❤️
This article helps you how to break line of text in react native, for HTML we know <br>
tag will do that but in react native. <br>
tag not available then today we will see how we can break line in react native.
Let start today topic how to use br tag in react native
Well, React Native is not supported the <br>
tag but we have another option and is \n
new line 😄.
We have to just put {"\n"}
this code on the text where we want to new line like below.
<Text> Hi, {"\n"} Infinitbility</Text>
Let’s understand with react native code example.
Below example, I have explained in both ways
Add new line using react native code
Use \n
in a text string
br tag example in react native using \n
new line
import React, { Component } from 'react';
import { View, Text } from 'react-native';
class ClassComponent extends Component {
constructor(props) {
super(props);
this.state = {
message : 'Hi,\nCurtis! Here',
}
}
render() {
const { names } = this.state;
return (
<View>
<Text>Hi {"\n"} {this.state.message}</Text>
</View>
);
}
}
export default ClassComponent;
Thanks For Reading…