title: How to get index when looping over object in JSX?
body: <p>I am using objects for data for faster access. To render the data as a list I am using map function from lodash. Inside the function I only have the key and value available. I wish to display the index of current item, for that I have done this <a href="https://jsfiddle.net/nandwana92/2a0p0e55/1/" rel="nofollow noreferrer">this way</a>. Is there a different/better way to do this?</p>
  
  <p><strong>Code Snippet</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="true">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class MyComponent extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        data: {
          'Rajasthan': 'Jaipur',
          'Tamilnadu': 'Chennai',
          'Maharashtra': 'Mumbai' 
        }
      };
    }
  
    render() {
      let count = 0;
  
      return (
        &lt;div&gt;
          {
            _.map(this.state.data, (value, key, list, index) =&gt; {
              return (
                &lt;div&gt;&lt;span&gt;{++count}.&lt;/span&gt;&lt;span&gt;State: {key}, Capital: {value}&lt;/span&gt;&lt;/div&gt;
              );
            })
          }
        &lt;/div&gt;
      );
    }
  
  }
  
  React.render(&lt;MyComponent /&gt;, document.getElementById('container'));</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.widget {
    width: 202px;
    margin: 100px auto;
    //    border:1px solid black;
    padding: 20px;
  }
  
  .name {
    color: red;
  }
  
  .default-label {
    border: 1px solid black;
    padding: 10px;
    margin-bottom: 10px;
    width: 180px;
  }
  
  .green-label {
    border: 1px solid green;
    padding: 10px;
    margin-bottom: 10px;
    width: 180px;
  }
  
  .default-input {
    border: 1px solid #eaeaea;
    padding: 10px;
    width: 180px;
  }
  
  .important-input {
    border: 2px solid red;
    width: 180px;
  }
  
  img.center {
    width: 100px;
    height: 100px;
    display: block;
    margin: 15px auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.5/react.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.5/react-dom.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"&gt;&lt;/script&gt;
  &lt;div id="container"&gt;
    &lt;!-- This element's contents will be replaced with your component. --&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>