Skip to content

Instantly share code, notes, and snippets.

@mrcflorian
Last active May 22, 2020 18:02
Show Gist options
  • Save mrcflorian/427ae7cdc5d6ece1461046b91bcb1112 to your computer and use it in GitHub Desktop.
Save mrcflorian/427ae7cdc5d6ece1461046b91bcb1112 to your computer and use it in GitHub Desktop.
...
import { firebase } from '../../firebase/config'
...
export default function RegistrationScreen({navigation}) {
...
const onRegisterPress = () => {
if (password !== confirmPassword) {
alert("Passwords don't match.")
return
}
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then((response) => {
const uid = response.user.uid
const data = {
id: uid,
email,
fullName,
};
const usersRef = firebase.firestore().collection('users')
usersRef
.doc(uid)
.set(data)
.then(() => {
navigation.navigate('Home', {user: data})
})
.catch((error) => {
alert(error)
});
})
.catch((error) => {
alert(error)
});
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment