import React, { Component } from "react"; import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground, Text } from "react-native"; import firebase from "firebase"; import { Picker } from "@react-native-picker/picker"; import { styles } from "../../config/styles"; import CustomButton from "../../components/CustomButton"; export default class RegisterScreen extends Component { constructor(props) { super(props); this.state = { username: '', email: '', password: '', interpreter: '', }; this.onRegister = this.onRegister.bind(this) }; onRegister() { const { username, email, password, interpreter } = this.state; firebase.auth().createUserWithEmailAndPassword(email, password) .then((result) => { if (interpreter) { firebase.firestore().collection("Interprete") .doc(firebase.auth().currentUser.uid) .set({ username, email, interpreter, }) console.log(result) } else { firebase.firestore().collection("Users") .doc(firebase.auth().currentUser.uid) .set({ username, email, interpreter, }) console.log(result) } }) .catch((error) => { console.log(error) }) } render() { return ( this.setState({ username })}/> this.setState({ email })}/> this.setState({ password })} secureTextEntry={ true }/> Are you an interpreter? this.setState({interpreter: itemValue})}> this.onRegister()}/> ); } }