title: React - filter by object property
body: <p>I am trying to filter object by property but I can't make it work.</p>
  
  <p><strong>Data in the object are structured like so:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/QxjAz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QxjAz.png" alt="enter image description here"></a></p>
  
  <p>I am fetching data by the UID and then mapping all the items from that object but I can't make the filter work.</p>
  
  <p><strong>Render method looks like so:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  render() {
      return(
        &lt;div&gt;
          {Object.keys(this.state.dataGoal)
            .filter(key =&gt; key.main == true)
            .map( (key, index) =&gt; {
              return &lt;div key={key}&gt;
                       &lt;h1&gt;{this.state.dataGoal[key].name}&lt;/h1&gt;
                       &lt;p&gt;{this.state.dataGoal[key].main}&lt;/p&gt;
                     &lt;/div&gt;
            })}
        &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any ideas what I am doing wrong?</p>
  
  <p>Thanks for any help,
  Jakub</p>