title: Uncaught TypeError: Cannot read property 'map' of undefined with React
body: <p>I have implemented a little test application in React to fetch data via AJAX, but it is not working as inteded, hence i get following error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'map' of undefinedInline JSX script
  </code></pre>
  
  <p>Code is as following:</p>
  
  <pre><code>&lt;div id="content"&gt;&lt;/div&gt;
  &lt;script type="text/jsx"&gt;   
  var Bodypart = React.createClass({
      render: function() {
          return (
              &lt;div&gt;
                  {this.props.name}
              &lt;/div&gt;
          )
      }
  })    
  
  var BodypartList = React.createClass({
      getInitialState: function() {
        return {data: []};
      },
      componentWillMount: function() {
        $.ajax({
          url: this.props.url,
          dataType: 'json',
          success: function(data) {
            this.setState({bodyparts: data});
          }.bind(this),
          error: function(xhr, status, err) {
            console.error(this.props.url, status, err.toString());
          }.bind(this)
        });
      },
      render: function() {
          var bodypartItems = this.state.bodyparts.map(function (bodypart) {
              return (
                  &lt;Bodypart 
                      name={bodypart.name} 
                  /&gt;
              );
          });
          return (
          &lt;div&gt;
              {bodypartItems}
          &lt;/div&gt;
          );
      }
  });    
  
  React.render(
      &lt;BodypartList url="/api/bodyparts/" /&gt;,
      document.getElementById('content')
  );
  &lt;/script&gt;
  </code></pre>
  
  <p>The response from <code>/api/bodyparts/</code>:</p>
  
  <pre><code>{
      "bodyparts": [
          {
              "id": 1, 
              "name": "Face"
          }, 
          {
              "id": 3, 
              "name": "Mouth"
          }, 
          {
              "id": 2, 
              "name": "Nose"
          }
      ]
  }
  </code></pre>