How to useJavaScript comments in ReactJS
These comments are made in the function and class definitions or where we are not writing any JSX code.
Syntax
// This is inline comment
/* This is a
multiline commnet */
Example: Comments for React Components. We can write comments in React using the double forward-slash // or the asterisk format /* */, similar to regular JavaScript.
App.js
import React, { Component } from 'react' ; // This is a comment class App extends Component { /* This is also a comment*/ render() { return ( <div> <h1>Welcome to w3wiki</h1> </div> ); } } export default App; |
Steps to tun the application: Use this command in the terminal window.
npm start
Output: This output will be visible on http://localhost:3000 on the browser.
How to write comments in ReactJS ?
To write comments in React JS we use the javascript comments and JSX object. It helps in adding useful information about the code and comment-out and ignore the extra code in the program.
Writing comments in React is done in these ways.
Table of Content
- Using JavaScript comments
- Using JSX object