Kuldeep
Kuldeep

Reputation: 83

reactjs render comments not working properly

I want to make comment some HTML and expression in render section.Below is the code.

  /*  <header className="App-header">
      <img src={logo} className="App-logo" alt="logo" />
      <h1 className="App-title">Welcome to React</h1>
      </header>
    */

But it given the below error on browser.

    ./src/App.js
  Line 49:  'logo' is not defined  no-undef

Search for the keywords to learn more about each error.

Can anyone tell me why the expression executed from commented section.

Upvotes: 0

Views: 63

Answers (2)

Franrey Saycon
Franrey Saycon

Reputation: 667

It might be because logo is not defined (meaning not declared) or imported anywhere.

I'm assuming you have a ,

const logo = <img src='./sample-dir/sample.jpg'/>

or

import logo from './sample-dir/sample.js'

somewhere in App.js? If not, that might be the cause.

And besides that to multi-line comment use:

{/*
    content here.
*/}

Upvotes: 0

RIYAJ KHAN
RIYAJ KHAN

Reputation: 15290

Right way to comment multiline statement in React.

enclose with curly braces.

{/* <header className="App-header">
      <img src={logo} className="App-logo" alt="logo" />
      <h1 className="App-title">Welcome to React</h1>
      </header> */}

Upvotes: 2

Related Questions