title: How to parse a JSON object from an external file in React using .map() in ES6 and a loop?
body: <p>I am trying to import a JSON object which is in an external file using React, and display its content inside a loop containing HTML. The goal is to display all that into a JQuery Slider (Slick).</p>
  
  <p>I think I succeeded in importing the JSON, but I can't display it. Most of the results I find on the internet are in ES5 also.</p>
  
  <p>Here is my slider.js file:</p>
  
  <pre><code>import React from 'react';
  import slidesData from './slides.json';
  
  export class Slider extends React.Component {
      constructor(){
          super();
          this.state = {
              slides: slidesData,
          }
      }
  
      render() {
          const list = this.state.slides.map(d =&gt; &lt;div className="classTest"&gt;ID HERE {slidesData.id} - DESCRIPTION HERE {slidesData.desc}&lt;/div&gt;);
          return (
              &lt;div className="carousel"&gt;
                  &lt;div className="data"&gt;
                      &lt;div&gt;list before {list} list after&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          );
      }
  }
  </code></pre>
  
  <p>slides.json:</p>
  
  <pre><code>[
      {
          "id": 1,
          "desc": "text desc 1"
      },
      {
          "id": 2,
          "desc": "text desc 2"
      },
      {
          "id": 3,
          "desc": "text desc 3"
      },
      {
          "id": 4,
          "desc": "text desc 4"
      }
  ]
  </code></pre>
  
  <p>Result in the browser:</p>
  
  <pre><code>list before
  ID HERE - DESCRIPTION HERE
  ID HERE - DESCRIPTION HERE
  ID HERE - DESCRIPTION HERE
  ID HERE - DESCRIPTION HERE
  list after
  </code></pre>
  
  <p>The files are in the same folder.
  So the <code>{list}</code> is displayed 4 times (like the items it contains) but it doesn't display the content. What am I missing?</p>
  
  <p>And then, I would like to repeat each <code>&lt;div className="data"&gt;</code> with a <code>for</code> loop displaying every time the JSON has content but until I find why the json is not getting displayed properly I don't want to try more complicated code.</p>
  
  <p>Thanks =)</p>