I am very new to react native with somewhat of a background in C(EE courses) and is just trying to understand the concepts. I'm currently folloing a react native course on Udemy.
I am trying to create a login form using firebase + react native. Here I would like to notify the user if an error occurs with their login.
I have two sets of code below in which I attempt to do the same thing, one of them works and the other one doesn't. I would like to understand why the first one works, and why the second one doesn't
This does work:
firebase.auth().createUserWithEmailAndPassword(email, password)
.catch((error) => {
this.setState({ error: error.message, loading: false });
});
Why do I need to put error on the left of the arrow function? From my understanding, whatever is on the left side of the arrow function can be seen as the "input", and the rightside is the system/output?
This doesn't work:
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(this.createFailure.bind(this))
createFailure() {
.catch((error) => {
this.setState({ error: error.message, loading: false });
});
}
This one gives me a parse error for the '.' in front of catch.
I don't think I quite understand how .catch works but I was only able to find catch() on mozilla without the '.' it seems that I lack some fundamental understanding of how certain elements work, are there any recommended Youtube series that explains these building blocks? I find documentations often have too many corner cases which makes everything quite confusing.