creating an application in react-native running into this problem. basically I should create a page that prints the data of the user currently logged in to the database (firebase). I managed to create a sort of leaderboard that prints all users with data, on another page, but I can not figure out where I was wrong. can someone help me?
https://snack.expo.io/@khal_d/proj-p-3
import React, { Component } from 'react'; import { View, TouchableOpacity, StyleSheet, Button, Text, ScrollView, ListItem } from 'react-native'; import { Input, Card} from 'react-native-elements'; import * as firebase from 'firebase'; export default class User extends Component { static navigationOptions = { title: 'UserInfo', }; state = { data: [], }; // Controllare qui componentDidMount(){ //leggere array dal db const currentUID = firebase.auth().currentUser.uid; const path ="/users/" + currentUID; const users = firebase.database().ref(path); users.on("value", snap => { console.log("log di snap" + snap); //ciclo var elenco = []; snap.forEach(child => { elenco.push({ name: child.val().name, surname: child.val().surname, email: child.val().email, image: child.val().image, }) }); console.log("altro log finale" + elenco); this.setState({data:elenco}) }); } // controllare fino a qua render() { return ( <ScrollView> <View> <Card> //fix evertything all'interno di card { this.state.data.map((l, i) => ( <ListItem key={i} leftAvatar={{ source: { uri: l.image } }} title={l.name} subtitle={l.surname} /> )) } </Card> </View> </ScrollView> ); } }