Undefined is not an object(evaluating '_this2.props.navigation.navigate')

Undefined is not an object(evaluating '_this2.props.navigation.navigate')
0

#1

import React from 'react';
import { StyleSheet, Text, View,TouchableOpacity, AppRegistry} from 'react-native';
import { StackNavigator } from 'react-navigation';
import Login from './screens/Login';


export default class App extends React.Component {
  /*
  static navigationOptions = {
    title: 'Home',
    headerstyle: {
      backgroundColor: 'powderblue',
    },
      headerTitleStyle: {
        color: '#FFFFFF'
      }
  };
  */

  render() {
    return (
      <View 
          style={styles.container} >   
          
          <View style={styles.boxContainer}>
            <View style = {[styles.boxContainer, styles.boxOne]}>
              <Text style={styles.paragraph}>Tido</Text>
            </View>
            
              <View style={styles.boxContainerToggle}>
                <TouchableOpacity style={[styles.boxContainer, styles.boxTwo]} onPress={() => this.props.navigation.navigate('Login')}>
                    <Text style={styles.paragraph}>Login</Text>
                </TouchableOpacity>
         
                <TouchableOpacity style={[styles.boxContainer, styles.boxThree]}>
                    <Text style={styles.paragraph}>Sign Up</Text>
                </TouchableOpacity>
              </View>          
          </View>
      
      </View>
      
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'column'
  },
  boxContainer: {
    flex: 1, // 1:3
    alignItems: 'center',
    justifyContent: 'center',
    
  },
  boxContainerToggle: {
    flex: 1, 
    flexDirection: 'row'
  },
  boxOne: {
    flex: 6, // 5:6
    backgroundColor: 'white',
    justifyContent: 'space-around',
    alignItems: 'center',
    
  },
  boxTwo: {
    flex: 1, // 1:6
    backgroundColor: 'powderblue',
    flexDirection: 'row',
    width: '50%',
    height: '100%'

  },
  boxThree: {
    flex: 1, // 1:6
    flexDirection: 'row',
    backgroundColor: 'skyblue',
    width: '50%',
    height: '100%'
  },
  paragraph: {
    margin: 24,
    fontSize: 27,
    fontWeight: 'bold',
    textAlign: 'center',
    color: '#34495e',
  }, 
});

const appScreens = StackNavigator({
  Index: { screen: App },
  Login: { screen: Login }
})

AppRegistry.registerComponent('tido', () => appScreens);



import React from 'react';
import {StyleSheet, View, TextInput, TouchableOpacity} from 'react-native';

export default class Login extends React.Component {
    /*
    static navigationOptions = {
        title: 'Home',
        headerstyle: {
          backgroundColor: 'powderblue',
        },
          headerTitleStyle: {
            color: '#FFFFFF'
          }
      };
      */
    
    constructor(props) {
        super(props)
    }
    
    render() {
        return(
            <View style={styles.container}>

                <View style={styles.boxContainer}>
                    <View style = {[styles.boxContainer, styles.boxOne]}>
                        <TextInput 
                            style={styles.inputBox} 
                            placeholder="username,email or phone"
                            placeholderTextColor="#00000">
                        </TextInput>

                        <TextInput 
                            style={styles.inputBox}
                            placeholder="password"
                            placeholderTextColor="#00000">
                        </TextInput>
                    </View>
            
                     <View style={styles.boxContainerToggle}>
                         <TouchableOpacity 
                            style={[styles.boxContainer, styles.boxTwo]}>
                         
                        </TouchableOpacity>
                    </View>          
                </View>   
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column'
    },
    boxContainer: {
        flex: 1, // 1:3
        alignItems: 'center',
        justifyContent: 'center',
        
      },
      boxContainerToggle: {
        flex: 1, 
        flexDirection: 'row'
      },
      boxOne: {
        flex: 6, // 5:6
        backgroundColor: 'white',
        justifyContent: 'space-around',
        alignItems: 'center',
        
      },
      boxTwo: {
        flex: 1, // 1:6
        backgroundColor: '#252525',
        flexDirection: 'row',
        width: '50%',
        height: '100%'

      },
      inputBox: {
          height: 40,
          marginBottom: 20,
          color: '#000000',
          paddingHorizontal: 10,

      },      
      paragraph: {
        margin: 24,
        fontSize: 27,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#34495e',
      },
});