title: How to avoid eval in my React app and what do you think about the logic?
body: <p>This is a simple react app. Do my components use the correct logic between composition and inheritance?</p>
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import './App.css';
  
  class Header extends React.Component {
      constructor(props) {
          super(props);
          this.handleClick = this.handleClick.bind(this); 
        }
       handleClick(e) {  /*  this.setState({
       evt: e.target */
       e.preventDefault();
       alert(e.target.tagName);
     
       }
    render() {
      return (
      
         &lt;div&gt;&lt;h1&gt;{this.props.title}&lt;/h1&gt;
         &lt;img  alt=&quot;logo&quot;src={this.props.value} onClick={this.handleClick}/&gt;
         &lt;/div&gt;//DIV CLOSING TAG
       
       
      );
    }
  }
   class Logo extends React.Component {
    render() {
      //const names = this.props.names;
      const src=&quot;/computer.png&quot;;
      const title=&quot;Votre site web à 49€ par mois&quot;;
     return  &lt;div&gt;
        &lt;Header key={src} value={src} title={title} /&gt;
      &lt;/div&gt;
    }
  }
  
  class Menu extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        url: &quot;http://localhost:3000/accueil&quot;,
        nomP: &quot;accueil&quot;
        
      };
    }
    /*changeColor = () =&gt; {
      this.setState({color: &quot;blue&quot;,brand:&quot;Cadillac&quot;});
    }*/
    doClick= (e)=&gt;{
       
       e.preventDefault();
       
       let nomPage=e.target.firstChild.nodeValue;
       
      
       this.setState({url: &quot;http://&quot;+e.target.host+&quot;/&quot;+nomPage.toLowerCase(),nomP:nomPage}); 
      
    }
    render() {
      //const nameP=this.props.nameP
      const nameP=[&quot;accueil&quot;,&quot;profil&quot;,&quot;contact&quot;];
      
      return (
      
      &lt;div&gt;
      {/*
          &lt;h1&gt;Url: {this.state.url}&lt;/h1&gt;
          &lt;p&gt;
           Nom de la page: {this.state.nomP}&lt;/p&gt;
      
      */}
       
        
          {nameP.map((nomPage)=&gt;(
           &lt;nav&gt;&lt;a id=&quot;&quot; href=&quot;&quot;key={nomPage} value={nomPage} className=&quot;link&quot; onClick={this.doClick}&gt;{nomPage.toUpperCase()}&lt;/a&gt;&lt;/nav&gt;))
          }
          
       
        &lt;Article npage={this.state.nomP} /&gt;
        &lt;/div&gt;
      );
    }
  }
  class Article extends React.Component {
      constructor(props) {
          super(props);
          //this.handleClick = this.handleClick.bind(this); 
        }
       handleClick(e) {  
     
       e.preventDefault();
       alert(e.target.tagName);
     
       }
    render() {
      
   
    let pages = {&quot;accueil&quot;:{&quot;titre&quot;:&quot;Lorem ipsum&quot;,&quot;contenu&quot;:&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed leo nibh, scelerisque a mi at, blandit cursus lacus. In hac habitasse platea dictumst. Duis iaculis odio feugiat nulla egestas, bibendum efficitur erat pulvinar. Fusce vestibulum nulla et scelerisque venenatis. Donec rutrum fringilla consectetur. Maecenas euismod augue in erat bibendum, sed dignissim risus placerat. Nam vel vestibulum odio. Etiam maximus dolor sem, nec sodales est ornare eu. Etiam dignissim leo tellus, ac placerat orci consectetur sit amet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nunc non metus non metus aliquam dapibus. &quot;},               
                 &quot;profil&quot;:{&quot;titre&quot;:&quot;Integer pulvinar&quot;,&quot;contenu&quot;:&quot;Integer pulvinar pharetra eros accumsan aliquam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas diam quam, congue non lectus porta, suscipit semper nulla. Nunc lobortis rutrum semper. Cras nibh urna, pretium et ipsum ullamcorper, aliquam pretium leo. Quisque id elementum urna, vitae aliquam quam. Integer finibus velit quis accumsan ornare. Phasellus dictum bibendum tincidunt. Nullam sodales risus dui, vel convallis felis accumsan id. Praesent mattis vulputate elit in dictum. Duis eget tristique erat. Vestibulum rutrum, risus et fermentum mattis, augue leo tincidunt diam, nec suscipit nisl lacus quis massa.&quot;},
                 &quot;contact&quot;:{&quot;titre&quot;:&quot;Sed aliquet&quot;,&quot;contenu&quot;:&quot;Sed aliquet tellus nunc, sit amet laoreet purus dictum vel. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum imperdiet vehicula magna, in malesuada odio. Nulla quis nibh fringilla, lobortis nisl sit amet, vehicula augue. Donec ac mi a augue tempor consectetur vel faucibus mi. Vestibulum mollis consectetur facilisis. In nec luctus est. Vestibulum mattis rutrum justo in interdum. Integer in lorem in nisi sagittis fermentum eget nec justo. Phasellus rhoncus augue vel ipsum posuere tempus. Nullam consequat ultricies sem sagittis finibus. Etiam gravida euismod rutrum. Nullam dapibus vulputate fringilla. Duis et risus cursus, congue leo at, mattis nisl. Etiam ullamcorper arcu id feugiat bibendum. Mauris condimentum mauris sed risus porttitor varius. &quot;}}; 
                 for (const property in pages) {
                     
                     if(property===this.props.npage.toLowerCase()){
                     
                     var nP=property;
                     
                     }
                     
                 
                  }
                  // THE TROUBLE WITH EVAL
                  let titre=eval(&quot;pages.&quot;+nP+&quot;.titre&quot;);
                  let contenu=eval(&quot;pages.&quot;+nP+&quot;.contenu&quot;);
                  
      return (
         
         &lt;div&gt;
         {/* &lt;h1&gt;{this.props.npage.toLowerCase()}&lt;/h1&gt;*/}
                                                               
              &lt;h1&gt;{titre}&lt;/h1&gt;
              &lt;p&gt;{contenu}&lt;/p&gt;
              
               &lt;Footer npage={nP} /&gt;
         &lt;/div&gt;//DIV CLOSING TAG
       
       
      );
    }
  }
  class Footer extends React.Component {
    constructor(props) {
          super(props);
          
    } 
    render() {
      
     return  &lt;div&gt;
        
        &lt;p className=&quot;copyright&quot;&gt;© Copyright &lt;strong&gt;{&quot;http://localhost:3000/&quot;+this.props.npage}&lt;/strong&gt;. All Rights Reserved. 2020&lt;/p&gt;
        &lt;p&gt;Designed by Laurent Gevaert&lt;/p&gt;
      &lt;/div&gt;
    }
  }
  
  
  
  
  
  
  
  ReactDOM.render(&lt;Logo /&gt;, 
                  document.getElementById('header')
  );
  ReactDOM.render(&lt;Menu /&gt;, 
                  document.getElementById('menu')
  );
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
      &lt;link rel=&quot;shortcut icon&quot; href=&quot;%PUBLIC_URL%/favicon.ico&quot;&gt;
      
      &lt;title&gt;React App&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id=&quot;header&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;menu&quot;&gt;&lt;/div&gt;
      &lt;!--
        This HTML file is a template.
        If you open it directly in the browser, you will see an empty page.
  
        You can add webfonts, meta tags, or analytics to this file.
        The build step will place the bundled scripts into the &lt;body&gt; tag.
  
        To begin the development, run `npm start`.
        To create a production bundle, use `npm run build`.
      --&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>It's not clear to me the links between the components relation between the components and how to avoid &quot;Eval&quot;</p>