title: Push objects into an array in reactjs
body: <p>I'm getting a list of objects as a response like this</p>
  
  <p><a href="https://i.stack.imgur.com/bqE8S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bqE8S.png" alt="enter image description here"></a></p>
  
  <p>As you can see the objects are not in an array. I want to push these objects into an array. I tried the following way</p>
  
  <pre><code>this.setState({
     countrydata: this.state.countrydata.push(datasnapshot.val()),
  })
  </code></pre>
  
  <p>But it didn't work. What's the correct approach to push these objects into an array?</p>
  
  <p>PS:</p>
  
  <pre><code>componentDidMount() {
          const countryCode = this.props.match.params.countryCode;
          var countryName = getName(countryCode);
          var firebaseHeadingref = firebase.database().ref(countryCode);
          firebaseHeadingref.once('value').then(datasnapshot =&gt; {
              this.setState({
                  countrydata: datasnapshot.val(),
                  countryName: countryName,
                  loading: false
              })
          });
      }
  </code></pre>