1const { email, username, password } = this.state;
2
3let rootRef = firebase.database().ref();
4
5rootRef
6 .child('users')
7 .orderByChild('username')
8 .equalTo(username)
9 .once('value')
10 .then(snapshot => {
11 if (snapshot.exists()) {
12 let userData = snapshot.val();
13 console.log(userData);
14 Alert.alert('username is taken');
15 return userData;
16 } else {
17 console.log('not found');
18 firebase
19 .auth()
20 .createUserWithEmailAndPassword(email, password)
21 .then(async user => {
22 console.log('Data created', user);
23 });
24 }
25});
26