title: React native How to return a value from a function to the component
body: <p>Im getting the 2 user authenticated from firebase database but how can I return a value from the function or is there any other solution to the authenticated user</p>
  
  <p>firebase.auth().onAuthStateChanged(user => {
              if (user) {</p>
  
  <pre><code>            firebase.database().ref('Usersyeah/').on('child_added', function (getdata) {
  
  
  
                  var newData = getdata.val().User
  
                  if (user.email == getdata.val().Email ){
  
                      if (getdata.val().User === 'User') {
                          var routes = [
                              {title: "Home",route: "Home",}
                              {title: "Pending Request",route: "Request"}]
                      } else {
                          var routes = [
                          {title: "USER",route: "Home"}
                          ]
                      }   
                  }
                   getdata.val().User })
              });
  
          } else {
  
          }
      })
  
  
  
      return (
  
          &lt;View&gt;
              &lt;TouchableOpacity style={{ backgroundColor: 'green', margin: 10, padding: 10 }}
                  onPress={this.mysubmit.bind(this)}&gt;
                  &lt;Text style={{ color: '#fff', alignItems: 'flex-end' }}&gt; SUBMIT &lt;/Text&gt;
              &lt;/TouchableOpacity&gt;
              &lt;Image
                  style={{ width: 250, height: 200 }}
                  source={require('../myimage/durian.jpg')}
  
              /&gt;
              {
                  routes.map(e =&gt; (
                      &lt;TouchableOpacity style={styles.link} onPress={_ =&gt; this.navigate(e.route)}&gt;
                          &lt;Text style={{ fontSize: 14 }}&gt;{e.title}&lt;/Text&gt;
                      &lt;/TouchableOpacity&gt;
                  )
                  )
              }
          &lt;/View&gt;
      )
  
  }
  </code></pre>