Navigate back to the homepage

React Native Text

Infinitbility
Text
January 27th, 2021 · 1 min read
React Native Text

This Article Part of React Native Tutorial Series want to start from scrach follow below link

https://infinitbility.com/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

1import React, { Component } from "react";
2import { Text, StyleSheet } from "react-native";
3
4class ReactNativeText extends Component {
5 constructor(props) {
6 super(props);
7 this.state = {
8 titleText: "Infinitbility",
9 bodyText: "We have the ability to build infinite way for us."
10 };
11 }
12
13 render() {
14 return (
15 <Text style={styles.baseText}>
16 <Text style={styles.titleText} onPress={this.onPressTitle}>
17 {this.state.titleText}
18 {"\n"}
19 {"\n"}
20 </Text>
21 <Text numberOfLines={5}>{this.state.bodyText}</Text>
22 </Text>
23 );
24 }
25}
26
27const styles = StyleSheet.create({
28 baseText: {
29 fontFamily: "Cochin",
30 padding: 20,
31 textAlign: 'center',
32 },
33 titleText: {
34 fontSize: 20,
35 fontWeight: "bold"
36 }
37});
38
39export 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.

1import { Text } from "react-native";

and use like below.

1<Text>Text Goes Here</Text>

How do you justify text in react native?

1<Text style={{textAlign: 'justify'}}>Text Goes Here</Text>

How do I align text to the right in react native?

1<Text style={{textAlign: 'right'}}>Text Goes Here</Text>

How do you strike text in react native?

1<Text style={{textDecorationLine: 'line-through',textDecorationStyle: 'solid'}}>Text Goes Here</Text>

How do I change the text color in react native?

1<Text style={{color: '#ffffff'}}>Text Goes Here</Text>

How do I center text in react native?

1<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
  7. React Native State
  8. React Native Props
  9. React Native Styling
  10. React Native Flexbox
  11. React Native Text
  12. React Native Textinput
  13. React Native Commands
  14. React Native ScrollView

Advances

  1. React Native Dark Mode
  2. React Native Fonts
  3. React Native SQLite
  4. React Native DatepickerAndroid
  5. React native ScrollView scroll to position
  6. How to align icon with text in react native
  7. React Native Image
  8. React Native Firebase Crashlytics
  9. React Native Async Storage
  10. React Native Share

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
  4. Unable to determine the current character, it is not a string, number, array, or object 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?
  9. how to disable drawer on the drawer navigation screen?
  10. Image not showing in ios 14 react native

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

More articles from Infinitbility

React Native Flexbox

React Native Flexbox

React Native Tutorial - React Native Flexbox

January 24th, 2021 · 3 min read
React Native Styling

React Native Styling

React Native Tutorial - React Native Styling

January 17th, 2021 · 1 min read
© 2021 Infinitbility
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]