How to annotate code in react native
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 "//".
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:
//标题栏 ① <View style = {styles.container}> ②<View style = {styles.headerView}><Text style = {styles.textHeaderStyle}>Header</Text> </View> //Tab栏 <ScrollableTabView style={styles.pagerView} renderTabBar={() => <DefaultTabBar />}//默认样式,Tab栏不可滑动 tabBarUnderlineStyle={styles.lineStyle}//下划线 tabBarActiveTextColor='#FF0000'> <MyFlatList //列表项 tabLabel = {dataSource1.tab} dataSource = {dataSource1} renderItem = {({item}) => <TouchableNativeFeedback //点击事件 onPress = {this.onPress.bind(this,item)}> <Text style = {styles.textMainStyle}>{item.key}</Text> </TouchableNativeFeedback> } />
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 = ( <Nav> {/* 一般注释, 用 {} 包围 */} <Person /* 多 行 注释 */ name={window.isLoggedIn ? window.name : ''} // 行尾注释 /> </Nav> );
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='right' textShadowColor='yellow' /*color='red' textShadowRadius='1'*/ > 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



React front-end and back-end separation guide: How to achieve front-end and back-end decoupling and independent deployment, specific code examples are required In today's web development environment, front-end and back-end separation has become a trend. By separating front-end and back-end code, development work can be made more flexible, efficient, and facilitate team collaboration. This article will introduce how to use React to achieve front-end and back-end separation, thereby achieving the goals of decoupling and independent deployment. First, we need to understand what front-end and back-end separation is. In the traditional web development model, the front-end and back-end are coupled

PyCharm multi-line comment shortcut keys: Make code comments more convenient and require specific code examples. In daily programming work, code comments are a very important part. It not only improves the readability and maintainability of the code, but also helps other developers understand the intent and design ideas of the code. However, manually adding code comments is often a time-consuming and tedious task. In order to make our code comments more efficient, PyCharm provides shortcut keys for multi-line comments. In PyCharm, we can use Ctrl+/

How to build a reliable messaging application with React and RabbitMQ Introduction: Modern applications need to support reliable messaging to achieve features such as real-time updates and data synchronization. React is a popular JavaScript library for building user interfaces, while RabbitMQ is a reliable messaging middleware. This article will introduce how to combine React and RabbitMQ to build a reliable messaging application, and provide specific code examples. RabbitMQ overview:

How to Optimize the Maintainability of Java Code: Experience and Advice In the software development process, writing code with good maintainability is crucial. Maintainability means that code can be easily understood, modified, and extended without causing unexpected problems or additional effort. For Java developers, how to optimize the maintainability of code is an important issue. This article will share some experiences and suggestions to help Java developers improve the maintainability of their code. Following standardized naming rules can make the code more readable.

ReactRouter User Guide: How to Implement Front-End Routing Control With the popularity of single-page applications, front-end routing has become an important part that cannot be ignored. As the most popular routing library in the React ecosystem, ReactRouter provides rich functions and easy-to-use APIs, making the implementation of front-end routing very simple and flexible. This article will introduce how to use ReactRouter and provide some specific code examples. To install ReactRouter first, we need

PHP, Vue and React: How to choose the most suitable front-end framework? With the continuous development of Internet technology, front-end frameworks play a vital role in Web development. PHP, Vue and React are three representative front-end frameworks, each with its own unique characteristics and advantages. When choosing which front-end framework to use, developers need to make an informed decision based on project needs, team skills, and personal preferences. This article will compare the characteristics and uses of the three front-end frameworks PHP, Vue and React.

iCloud Keychain makes it easier to manage your passwords without relying on memorizing or guessing website or usernames. You can do this by adding notes to existing passwords for apps and websites in iCloud Keychain. In this post, we will explain how to add notes to the passwords you save in iCloud Keychain on iPhone. Requirements There are some requirements you need to meet to use this new feature in iCloud Keychain. iPhone running iOS 15.4 or later Passwords stored in iCloud Keychain A valid Apple ID A valid internet connection How to add notes to saved passwords It goes without saying that you should store some passwords in iCloud Keychain

Integration of Java framework and React framework: Steps: Set up the back-end Java framework. Create project structure. Configure build tools. Create React applications. Write REST API endpoints. Configure the communication mechanism. Practical case (SpringBoot+React): Java code: Define RESTfulAPI controller. React code: Get and display the data returned by the API.
