The text component is a basic component in react, similar to the TextView component in Android, to display basic text information, which, in addition to the basic display layout, can be nested, set styles, and can do events (for example, click) processing. Let's take an example:
1 import React, {Component} from ‘react’;
2 import {
3 AppRegistry,
4 StyleSheet,
5 Text
6} from ‘react-native’;
7
8 class AndroidWdd03 extends Component {
9 render () {
10 return (
11 <Text style = {styles.father}>
12 parent text
13 <Text style = (styles.son)>
14 subtext
15 </ Text>
16 </ Text>
17);
18}
19}
20
21 const styles = StyleSheet.create ({
22 father: {
23 margin: 10,
24 textAlign: ‘center’,
25 color: ‘red’,
26 fontSize: 24,
27 fontFamily: ‘Cochin’
28},
29 son: {
30 color: ‘green’,
31 fontWeight: ‘bold’,
32 fontSize: 18
33}
34});
35
36 AppRegistry.registerComponent (‘AndroidWdd03’, () => AndroidWdd03);
The above example uses the text nesting way, the outermost text style father defines the related style, the inner layer styles style defines the related style, we can see the running effect, if the inner layer does not rewrite the outer defined style, then the inner layer inherits. If you override a style, the inner layer renders according to the style you define, which is similar to a CSS style sheet.
The above example mainly defines the layout, font size, font style, color and other related styles
Reference: http://www.lcode.org/%E3%80%90react-native%E5%BC%80%E5%8F%91%E3%80%91react-native%E6%8E%A7%E4%BB%B6%E4%B9% 8btext%e7%bb%84%e4%bb%b6%e8%ae%b2%e8%a7%a3/
The text component of the "React native development" React native control explains-ES6 syntax