title: ReactJs: Displaying the values inside of a state object
body: <p>I am trying to display the values inside a state object:<br>
  I have tried two methods:  </p>
  
  <blockquote>
    <p>Method 1:</p>
  </blockquote>
  
  <pre><code> &lt;tbody&gt;
                      {Object.keys(this.state.operationSavInformation).map(
                        function(key, index) {
                          return (
                            &lt;tr key={key}&gt;
                              &lt;td&gt;{`${key}:`}&lt;/td&gt;
                              &lt;td&gt;
                                &lt;strong&gt;
                                  {this.state.operationSavInformation[key]}
                                &lt;/strong&gt;
                              &lt;/td&gt;
                            &lt;/tr&gt;
                          );
                        }
                      )}
                    &lt;/tbody&gt;
  </code></pre>
  
  <blockquote>
    <p>Method 2:</p>
  </blockquote>
  
  <pre><code>&lt;tbody&gt;
                  {Object.keys(this.state.operationSavInformation).forEach(
                    function(key) {
                      var value = this.state.operationSavInformation[key];
                      return (
                        &lt;tr key={key}&gt;
                          &lt;td&gt;{`${key}:`}&lt;/td&gt;
                          &lt;td&gt;
                            &lt;strong&gt;value&lt;/strong&gt;
                          &lt;/td&gt;
                        &lt;/tr&gt;
                      );
                    }
                  )}
                &lt;/tbody&gt;
  </code></pre>
  
  <p>Both give this error:  </p>
  
  <pre><code>TypeError: Cannot read property 'state' of undefined
  </code></pre>
  
  <p>Unfortunately, these are the only two ways I've found to <strong>map over</strong> an object values in javaScript. This would work if the object was defined normally. However the problem here is that <strong>this</strong> is not accessible inside <code>map</code> or <code>forEach</code>, that's why I get the error.  </p>