title: React Native Firebase Authentication Error
body: <p>I'm trying to create the login user account system and for some reason it is recognizing incorrect passwords after navigating to the home screen instead of before.  (The code I am referring to is the the login() function).  I put console log statements to determine this and 'console.log(errorCode);' is the last thing that is outputted.  Can someone please explain the logic of the code I have written and why incorrect passwords are only recognized at the end? 
  The order of console output is 
  "Logging in"
  "Navigate to Home"
  "Login finish"
  "auth/wrong-password?
  Thanks so much.</p>
  
  <pre><code>import React, {Component} from 'react';
  import {
    View,
    Text,
    TouchableHighlight,
    TouchableOpacity,
    TextInput,
    KeyboardAvoidingView
  } from 'react-native';
  import Input from './Input';
  import Icon from 'react-native-vector-icons/MaterialIcons';
  import {firebaseApp} from './App';
  import {Tabs} from './Router';
  import {StackNavigator, TabNavigator} from 'react-navigation';
  import { Root } from './Router';
  
  export default class LoginScreen extends Component {
    constructor(props) {
      super(props)
  
      this.state = {
        email: '',
        password: '',
        status: '',
        success: ''
      }
  
      this.login = this.login.bind(this);
  
    }
  
    login(){
      console.log("Logging in");
      var errorCode;
      var errorMessage;
      firebaseApp.auth().signInWithEmailAndPassword(this.state.email, this.state.password).catch(function(error) {
          errorCode = error.code;
          console.log(errorCode);
          errorMessage = error.message;
      });
  
        if (errorCode === 'auth/wrong-password') {
          console.log("Wrong password");
          alert('Wrong password.');
        } else {
          console.log("Navigate to Home");
          this.props.navigation.navigate('Home');
        }
  
        //console.log(error);
        console.log("Login finish");
  
  
      /*firebaseApp.auth().signInWithEmailAndPassword(this.state.email, this.state.password).catch(function(error) {
        console.log(error.code);
        console.log(error.message);
      })
  
      this.props.navigation.navigate('Home');
  
      console.log("Navigate to Home");*/
    }
  
    render() {
      var styles = require('./Styles');
      const {navigate} = this.props.navigation;
  
      return(
        &lt;KeyboardAvoidingView behavior='padding' style={styles.loginContainer}&gt;
          &lt;Text style={styles.loginHeader}&gt;PRINCETON EVENTS&lt;/Text&gt;
          &lt;TextInput
            style={styles.loginInput}
            placeholder="Email"
            autoCapitalize='none'
            onChangeText={(text) =&gt; this.setState({email: text})}
            value={this.state.email}
            returnKeyType='next'/&gt;
          &lt;TextInput
            secureTextEntry
            style={styles.loginInput} placeholder="Password"
            onChangeText={(text) =&gt; this.setState({password: text})}
            value={this.state.password}
            autoCapitalize='none'
            returnKeyType='go'/&gt;
          &lt;TouchableOpacity style={styles.loginButton}&gt;
            &lt;Text style={styles.loginText} onPress={this.login}&gt;LOGIN&lt;/Text&gt;
          &lt;/TouchableOpacity&gt;
          &lt;TouchableOpacity
            style={styles.loginButton}
            onPress = {() =&gt; navigate('CreateAccount')}&gt;
            &lt;Text style={styles.loginText}&gt; CREATE ACCOUNT &lt;/Text&gt;
          &lt;/TouchableOpacity&gt;
        &lt;/KeyboardAvoidingView&gt;
      );
  
  }
  }
  </code></pre>