The text component of the "React native development" React native control explains-ES6 syntax

Source: Internet
Author: User



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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.