Javascript – Retrieves data from the Firebase to respond natively and display the data






import React, {Component} from & # 39; react & # 39 ;;
{StyleSheet, Button, View, Text} off & # 39; react-native & # 39; import;
{createAppContainer} from & # 39; react-navigation & # 39; import;
{createStackNavigator} off & # 39; respons-navigation-stack & # 39; import;
Firebase from & # 39; Firebase & # 39; import;
import {FirebaseDatabaseProvider} from "firebase";

const userData = ();
Export standard class main screen extends component {
state = {currentUser: null}
componentDidMount () {
const {currentUser} = firebase.auth ()
const ref = firebase.database (). ref ("users /" + currentUser.uid) .once ("value", function (snapshot) {
userData.push ({
name: snapshot.val (). Surname,
email: snapshot.val (). e-mail,
cpf: snapshot.val (). cpf,
tipo: snapshot.val (). tipo
})
alert (JSON.stringify (userData, null, 2));
});
this.setState ({currentUser})
//alert(JSON.stringify (ref, null, 2));
}

render () {
const {currentUser} = this.state;
Return (
      
        Hello {currentUser && currentUser.uid}! 

Logado como! Teate
) } } const styles = StyleSheet.create ({ Container: { flex: 1, justifyContent: & # 39; center & # 39 ;, alignItems: & # 39; center & # 39; } })