CodeReaper CodeReaper - 1 year ago 115
React JSX Question

How to comment HTML within React written in TypeScript?

class MyClass extends React.Component<any, any> {
render(): JSX.Element {
return (<div>
/*<div>{this.state.myVal} Not Working</div>*/
///<div>{this.state.myVal} Not Working</div>
<!--<div>{this.state.myVal} Not Working</div>-->

I have tried the above 3 ways to comment an entire line. None seem to work. I'm using Visual Studio if it makes a difference.

Answer Source

Wrap it in curly braces.

{/* <div>{this.state.myVal} Not Working</div> */}

A multi-line comment would be:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download