Home  >  Article  >  Web Front-end  >  How to annotate code in react native

How to annotate code in react native

青灯夜游
青灯夜游Original
2020-12-21 17:07:073457browse

How to comment code in react native: 1. Within the HTML tag node, use "{/* */}" to comment; 2. Outside the HTML tag node, use "/**/" to comment, a single line can be commented with "//".

How to annotate code in react native

The operating environment of this tutorial: windows7 system, react native0.6&&react16 version, this method is applicable Suitable for all brands of computers.

Recommended related tutorials: React video tutorial

React Native comments are too particular, errors are reported frequently, and they are not smart. Here is a summary of the comments .

Problem presentation

The code is as follows:

        //标题栏
        ① 11676cce6cd603bf0d82d9fd0667526d
            ②70dc183307a8935ad2def18e3a70a45e3e10c0c3bd26d984e00128fc4c74ac1bHeaderb735fb8965edb39ac28662131d16c063
            3d260b73c372472a96940693fb62cbcc
          //Tab栏
          0163496f741cf4a3a6d60244dd3fd42a 67c8380713b32081c3104ec94ba56d81}//默认样式,Tab栏不可滑动
              tabBarUnderlineStyle={styles.lineStyle}//下划线
              tabBarActiveTextColor='#FF0000'>         

          94f685590481c166e49f637426936dfd
            eb1064aab53c77a64ebb21adda5a990d
                b4a226bead624681d8cc0bc767df382c{item.key}b735fb8965edb39ac28662131d16c063
            1d37001aadc107a81e197a893ba89ea3
          }
          />

It runs normally before adding comments. After adding comments, various reports are reported. Error.
It’s very strange. After investigation, we found:

>. Please note that when using // as a comment, the comment content must not be in any html tag, otherwise it will be regarded as the text content to be displayed.

For example, although the //Tab bar above is outside ②, it is still inside ①. It will be regarded as the text to be displayed, and an error will be reported. At this time, the comment should be {/* General comment , surrounded by {}" for multiple lines */}

#react native uses JSX language, combining JS and html. All comments are as follows:

var content = (
  f4fdefacb9d1b27eee008428b9326e3c
    {/* 一般注释, 用 {} 包围 */}
    04fdb84174d15ff488bf05723927c9f0
  63b39a681ee211de3e07344ad97de9bf
);

Add comments in JSX Easily they are just JS expressions. You just need to surround the part to be commented with {} within the child nodes of a tag (not the outermost).

class ReactDemo extends Component {
  render() {
    return (      <View style={styles.container}>
        {/*标签子节点的注释*/}
        <Text style={styles.welcome}
          //textAlign=&#39;right&#39;
          textShadowColor=&#39;yellow&#39;
          /*color=&#39;red&#39;
          textShadowRadius=&#39;1&#39;*/
          >
          React Native!        </Text>
      </View>
    );
  }
}

Comment outside the tag node and The usual comments are the same, use "/**/", use "//" for a single line.

Note:

When using // as a comment, please note that the comment content must not be in any html tag, otherwise it will be regarded as The text content to be displayed

comments are generally {/**/} for multiple lines. If it is not within any tag, you can use //, } followed by comments //

More programming related knowledge, Please visit: Introduction to Programming! !

The above is the detailed content of How to annotate code in react native. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn