title: Set State Using getInitialProps of Nextjs for firebase DB
body: <p>Am trying to build Nextjs app . Am using GetInitialProps to do the SSR through Firebase functions . In getInitialProps  , i try to do a database.ref().child  and pass the value to the UI . </p>
  
  <p><strong>How can i set the changed value in a state variable so that anytime the value in DB is changed , it reflects in UI .</strong> </p>
  
  <p>Currently am returning the value in getInitialProps , and it doesn't reflect when there is a change in DB value . The changed value gets printed on server though when i put a console logger .</p>
  
  <p><strong>CODE :</strong> </p>
  
  <pre><code>static async getInitialProps({ req,query }) {
  
      var customer;
  
      database.ref().child('someKey').child)
      .on('value', function(snapshot) {
          console.log(snapshot.val());
          customer = snapshot.val();
          console.log(customer.name);
          this.setState({waitNum : customer.waitNum});
          return {customer};
      });
  
      console.log("Hi Here");
      return {customer};
  }
  </code></pre>