Given the following JSX code:
<div className="my-class"></div>
How can I comment out the className="my-class"
?
/*className="my-class"*/
does not work{/* className="my-class" */}
does not work (TS1005:'...' expected
)Syntax. JSX comments begin and end with curly braces {} . Followed by the opening curly brace is a forward slash and an asterisk. After that is the comment and lastly, an asterisk, a forward slash and the closing curly brace.
tsx extension is used when we want to embed JSX elements inside the files while . ts is used for plain Typescript files and do not support adding JSX Elements. Save this answer.
A TSX file is a TypeScript (. TS) file written using JSX syntax. It contains code that is most likely part of a single-page or mobile application. TSX files can be opened in any text editor, but are meant to be opened in source code editors.
/*className="my-class"*/ does not work
Works fine:
You can also do:
<div
// className="my-class"
>Hello</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With