title: How to get previous route in react navigation?
body: <p>I am user react navigation in react native application. After login I navigate to Home screen from where I want to sign out I should be navigate to previous screen(say Login). But inside navigation props I am unable to find any way to Login screen back without use of goBack function. <strong>My navigation is little messy please see my navigation  carefuly.</strong></p>
  
  <p>This is my Navigators</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react';
  import{ View, Text } from 'react-native';
  
  // Navigators
  import { DrawerNavigator, StackNavigator, TabNavigator } from 'react-navigation'
  
  // Drawer Screens
  import Welcome from '../../screens/Welcome';
  import Profile from '../../screens/Profile';
  
  // Tab Screens
  import Home from '../../screens/Home';
  import Message from '../../screens/Message';
  
  //TabNav
  const routeConfigs = {
      Home: {
          screen: Home,
          navigationOptions: {
            title: 'Home'
          }
      },
      Message: {
          screen: Message,
      },
  }
  
  const tabNavigatorConfig = {
      // tabBarComponent: tabBarComponent,
      tabBarPosition: 'top',
      lazy: true,
      tabBarOptions: {
          activeTintColor: 'yellow',
          inactiveTintColor: 'gray',
          style: {
              backgroundColor: '#8e24aa',
            },
          activeBackgroundColor: 'green',
      },
      header: 'screen'
  }
  
  export const TabNav = TabNavigator(routeConfigs, tabNavigatorConfig);
  
  //Used Stack to get Header above TabBar
  export const StackNav = StackNavigator({TabNav: { screen: TabNav }});
  
  //DrawerNav 
  export const DrawerNav = DrawerNavigator (
      {
          Welcome: { screen: Welcome},
          Profile: { screen: Profile },
          StackNav: { screen: StackNav}, // Stack Navigator to get Header on each Tabs
      },
      {
          initialRouteName: 'Welcome',
          drawerBackgroundColor: '#98eef3',
      }
  );</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is Welcome or say Login Screen</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
  import { View, Text, StyleSheet, Button, TouchableOpacity, Modal, BackHandler, Alert, Image } from 'react-native';
  import { connect } from 'react-redux';
  import firebase from 'firebase';
  import {
      loginUser
  } from '../actions';
  import Input from '../components/Input';
  import Spinner from '../components/Spinner';
  
  class Welcome extends Component {
      constructor(props){
          super(props);
          this.state = {
              modalVisible: false,
              email: '',
              password: '',
          }
          this.renderHome = this.renderHome.bind(this);
      }
  
      componentDidMount() {
          BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
      }
  
      componentWillUnmount() {
          BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
        }
  
      handleBackButton = () =&gt; {
          Alert.alert(
              'Exit App',
              'Exiting the application?', 
              [
                  {text: 'Cancel', onPress: () =&gt; console.log('Cancel Pressed'), style: 'cancel'}, 
                  {text: 'OK', onPress: () =&gt; BackHandler.exitApp()}
              ], 
              { cancelable: false }
          )
          return true;
      } 
  
      static navigationOptions = () =&gt; ({
          drawerLockMode: 'locked-closed'
      })
  
      loginButtonPress() {
          this.props.loginUser(this.state.email, this.state.password);
      }
  
      renderHome(){
          this.props.navigation.navigate('StackNav');
      }
  
      renderLoginButton(loading){
          if(loading){
              return &lt;Spinner /&gt;;
          }else{
              return (
                  &lt;View style={{alignItems: 'center'}}&gt;
                      &lt;TouchableOpacity style={styles.button} onPress={this.loginButtonPress.bind(this)} &gt;
                          &lt;Text style={styles.buttonText}&gt;Login&lt;/Text&gt;
                      &lt;/TouchableOpacity&gt;
                  &lt;/View&gt;
              );
          }
      }
  
      render() {
          return (
              &lt;View style={styles.container}&gt;
                  {(this.props.user)?this.renderHome():null}
                  &lt;View style={{flex: 3, justifyContent: 'center'}}&gt;
                      &lt;Input
                          placeholder="Email"
                          keyboardType="email-address"
                          value={this.state.email}
                          onChangeText={(email) =&gt; this.setState({email})}
                      /&gt;
                      &lt;Input
                          placeholder="Password"
                          value={this.state.password}
                          onChangeText={(password) =&gt; this.setState({password})}
                          secureTextEntry
                      /&gt;
                      {this.renderLoginButton(this.props.loading)}
          );
      }
  }
  
  mapStateToProp = ({auth}) =&gt; {
      return {
          user: auth.user,
          error: auth.error,
          loading: auth.loading,
      }
  }
  
  export default connect(mapStateToProp, { loginUser })(Welcome);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is Home screen</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
  import { View, Text, Button, Alert, Animated, BackHandler } from 'react-native';
  import { connect } from 'react-redux';
  import Header from '../components/Header';
  import Ionicons from 'react-native-vector-icons/Ionicons';
  export class Home extends Component {
  
      constructor(props){
          super(props);
      }
  
      componentDidMount() {
          BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
      }
  
      componentWillUnmount() {
          BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
        }
  
      handleBackButton = () =&gt; {
          Alert.alert(
              'Exit App',
              'Exiting the application?', 
              [
                  {text: 'Cancel', onPress: () =&gt; console.log('Cancel Pressed'), style: 'cancel'}, 
                  {text: 'OK', onPress: () =&gt; BackHandler.exitApp()}
              ], 
              { cancelable: false }
          )
          return true;
      }
      
      static navigationOptions = ({navigation}) =&gt;( {
          title: 'Home',
          header: &lt;Header headerTitle={navigation.state.routeName}/&gt;,
          headerTintColor: '#fff',
        });
  
      render(){
          console.log(this.props.user) // after signout getting undefined
          return (
              &lt;View 
                  style={{height: 1000}}
              &gt;
  
                  &lt;View style={{height: 1000}}&gt;
                    &lt;Text&gt;Home&lt;/Text&gt;
                  &lt;/View&gt;
              &lt;/View&gt;
          );
      }
  }
  
  mapStateToProp = ({auth}) =&gt; {
      return {
          user: auth.user,
      }
  }
  
  export default connect(mapStateToProp, null)(Home);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Signout is correctly working  but need to navigate back to welcome/login screen.</p>