Skip to main content
InterviewHubPRO
Section Overview
Q27

Question 27 of 407

General

7%
React Core & Hooks (407 Qs)•General

How to write comments in React?

mid LevelCode ExamplereactGeneral

The comments in React/JSX are similar to JavaScript Multiline comments but are wrapped in curly braces.

Single-line comments:

jsx
<div>
{/* Single-line comments(In vanilla JavaScript, the single-line comments are represented by double slash(//)) */}
{`Welcome ${user}, let's play React`}
</div>

Multi-line comments:

jsx
<div>
{/* Multi-line comments for more than
one line */}
{`Welcome ${user}, let's play React`}
</div>

You can use // and /* */ in JS logic, hooks, and functions.