This Article Part of React Native Tutorial Series want to start from scrach follow below link
https://infinitbility.github.io/react-native/table-of-contents
Text
The Text component is one of the most common React Native components — we use it whenever we need to display text in our app.
This component can be nested and it can inherit properties from parent to child. This can be useful in many ways. We will show you example of capitalizing the first letter, styling words or parts of the text, etc.
React Native Text example
import React, { Component } from "react";
import { Text, StyleSheet } from "react-native";
class ReactNativeText extends Component {
constructor(props) {
super(props);
this.state = {
titleText: "Infinitbility",
bodyText: "We have the ability to build infinite way for us."
};
}
render() {
return (
<Text style={styles.baseText}>
<Text style={styles.titleText} onPress={this.onPressTitle}>
{this.state.titleText}
{"\n"}
{"\n"}
</Text>
<Text numberOfLines={5}>{this.state.bodyText}</Text>
</Text>
);
}
}
const styles = StyleSheet.create({
baseText: {
fontFamily: "Cochin",
padding: 20,
textAlign: 'center',
},
titleText: {
fontSize: 20,
fontWeight: "bold"
}
});
export default ReactNativeText;
Common Q & A
Common Q & A section explain commonly question ask on google.
How do I add text in react native?
Alrady added example on Text Section but hear explaining steps to add Text
.
First import Text component from react native.
import { Text } from "react-native";
and use like below.
<Text>Text Goes Here</Text>
How do you justify text in react native?
<Text style={{textAlign: 'justify'}}>Text Goes Here</Text>
How do I align text to the right in react native?
<Text style={{textAlign: 'right'}}>Text Goes Here</Text>
How do you strike text in react native?
<Text style={{textDecorationLine: 'line-through',textDecorationStyle: 'solid'}}>Text Goes Here</Text>
How do I change the text color in react native?
<Text style={{color: '#ffffff'}}>Text Goes Here</Text>
How do I center text in react native?
<Text style={{color: '#center'}}>Text Goes Here</Text>
More From React Native Tutorial
Basics
1. Introduction To React Native
2. React Native Environment Setup using expo
3. React Native Environment Setup for windows
4. React Native Environment setup on Mac OS
5. React Native Environment setup on linux
6. React Native Project Structure
Advances
4. React Native DatepickerAndroid
5. React native ScrollView scroll to position
6. How to align icon with text in react native
8. React Native Firebase Crashlytics
Error & Issue Solution
1. Task :app:transformDexArchiveWithDexMergerForDebug FAILED In React Native
2. Expiring Daemon because JVM heap space is exhausted In React Native
3. Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED In React Native
5. App crashed immediately after install react native video or track player
6. how to delete SQLite database in android react native
7. React native material dropdown twice click issue
8. How to get the current route in react-navigation?