Hello Friends đź‘‹,

Welcome To Infinitbility! ❤️

This tutorial wil help you to add comment in react native code, here you will get example of react native render comment, single line comments and multiple line comments.

If you’r familiar with jsx and js then you already know it.

Let start today topic How to comment in react native

In React Native comments syntax depend upon where you want comments.

React Native render comments example

Here render comment means where you use components.

Well, you want write comment in react native render method then you have to use simple comment syntax with curly brace somethings like {/* Your comment */}.

ReactNativeRenderComment.js

import React from 'react';
import {View,Text} from 'react-native';
const App = () => (
  <View>
    {/* <Text>Hello World</Text> */}
  </View>
);
export default App;

Other comments example

In other types comments we will use any place except render components. and hear also options for single line comment and multiple line comment.

let start with single line comment.

  • Single line comment example

single line comment syntax

// single line comment

SingleLineCommentExample.js

import React from 'react';
import {Text} from 'react-native';

// HelloWorld function
const HelloWorld = ({name}) => <Text>Hello World {name}!</Text>;
export default HelloWorld;
  • Multiple line comment example

Multiple line comment syntax

/**
 * Multiple line comment example
 * 
 * @param {*} param0 
 * @returns 
 */

MultipleLineCommentExample.js

import React from 'react';
import {Text} from 'react-native';

/**
 * Print hello world
 * 
 * @param {*} name 
 * @returns 
 */
const HelloWorld = ({name}) => <Text>Hello World {name}!</Text>;
export default HelloWorld;

Thanks For Reading…