title: React JS : this.setState and JSON.parse
body: <p>I have a problem, I don't know how I can fix it. I am doint a request to my api and it responds with an object like this :</p>
  
  <pre><code>{"_id":"5a806648300caf0072c7254a","mail":"email@email.com"}
  </code></pre>
  
  <p>I want to print to my react component the mail. In my "componentDidMount()" function I get the mail, so there is no problem with my api. But when I want to set the state of my "users" variable, I can not print the variable in my component... It says that it's undefined.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>class UserList extends Component {
      constructor(props){
          super(props);
          this.state = {users:[]}
      }
      componentDidMount() {
          //here my function that store the response from my api
          GetData('http://localhost:3333/users', 'username=admin', 
          (res) =&gt; 
          {
              this.setState({users: JSON.parse(res)});
              //Here I can log the mail
              console.log(this.state.users[0].mail);
          })
      }
      render() {
          return (
              &lt;table&gt;
                  &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;EMAIL&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;tr&gt;
                          //Here it is 'undefined'
                          &lt;td&gt;{this.state.users[0].mail}&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
          );
      }
  }
  </code></pre>
  
  <p>Thank you for your help !</p>