title: How to define variable in class component
body: <p>I have 2 basic components here and I get an error when trying to map over my elements:</p>
  
  <pre><code>class EleMenu extends Component {
    render(){
      return (
        &lt;li className="eleMenu"&gt;{this.props.name}&lt;/li&gt;
      )
    }
  }
  
  class MainMenu extends Component {
    const rows = []
    this.props.elements.forEach()    //error here
      (e) =&gt; {
        rows.push(
          &lt;EleMenu
            name={e.name}
          &gt; 
          &lt;EleMenu/&gt;
        )
      }
    );
  
    render(){
      return (
        &lt;ul className="mainMenu"&gt;
          {rows}
        &lt;/ul&gt;
      )
    }
  }
  </code></pre>
  
  <p>It says unexpected token for the line: <code>this.props.elements.forEach()</code></p>