-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestpage.js
More file actions
62 lines (42 loc) · 1.63 KB
/
testpage.js
File metadata and controls
62 lines (42 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// NOTE: LOGIN AND LoginForm ARE NOT USE FOR THIS PROJECT
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, KeyboardAvoidingView, TextInput, TouchableOpacity, Alert, Button, StatusBar} from 'react-native';
import { StackNavigator,DrawerNavigator } from 'react-navigation';
// IMPORT COMPONENTS
import firebase from "firebase";
export default class TestPage extends React.Component {
static navigationOptions = {
title: 'TestPage',
};
testFirebase(){
let user = firebase.auth().currentUser;
let userId = user.uid;
let ref = firebase.database().ref('users/' + userId ).orderByKey();
ref.once("value")
.then(function(childSnapshot) {
//snapshot.forEach(function(childSnapshot) {
childSnapshot.forEach(function(child){
// let key = child.key;
// console.log("childd" + key);
// console.log("childd" + key.child("userName").val());
// //console.log("chidddd" + childSnapshot.key.val());
//})
//key will be "ada" the first time and "alan" the second time
var key = child.key;
console.log("childSnapShot" + key);
// childData will be the actual contents of the child
var childData = child.val();
console.log("childData" + childData);
});
});
// });
// console.log("heeeeeello " + ref.userName);
}
render() {
return (
<View>
<Text onPress = {this.testFirebase} >Hello</Text>
</View>
)
}
}