2

I tried everything which I saw on the web but none of them solved my problem.
it always gives me “Cannot read property ‘navigate’ of undefined.

How could I solve this?

I send info from Page1 to Header, But I couldnt send from Header to Page1. and also how can go from header to page1 I mean how to open Page1 with clicked some button

import React, { Component } from 'react';
import { View, Text, FlatList } from 'react-native';
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);

export default class Header extends Component {

    constructor(props){
        super(props);
    }

    render() {
        console.warn(this.props.navigation);
    return (
        <View style= {styles.headerStyle}>
            <View style= {[styles.View2, {backgroundColor: 'rgba(116,185,255,0.3)'}]} >
                <Text style={[styles.childText, {color:'#74b9ff'}]} >{this.props.color1}</Text>
            </View>
            <View style= {[styles.View2, {backgroundColor: 'rgba(255,234,167,0.3)'}]}>
                <Text style={[styles.childText, {color:'#ffeaa7'}]} >{this.props.color2}</Text>
            </View>
            <View style= {[styles.View2, {backgroundColor: 'rgba(204,255,204,0.3)'}]}>
                <Text style={[styles.childText, {color:'#ccffcc'}]} >0</Text>
            </View>
            <View style= {[styles.View2, {backgroundColor: 'rgba(255,128,128,0.3)'}]}>
                <Text style={[styles.childText, {color:'#ff8080'}]} >0</Text>
            </View>
            <View style= {[styles.View2, {backgroundColor: 'rgba(207,207,176,0.3)'}]}>
                <Text style={[styles.childText, {color:'rgba(207,207,176,0.3)'}]} >0</Text>
            </View>
        </View>
    );
 };
}

here is my Page1 where I use Header Component.

import React, { Component } from 'react';
import { View, Text, FlatList, Image, ScrollView} from 'react-native';
import DOMParser from 'react-native-html-parser';
import axios from 'axios';
import Header from './Header';
import Bar from './Bar';
import Footer from './Footer';

const Blue = [];
const Yellow = [];

export default class Page1 extends Component {    

    state = {
         leader: []
    }

    componentWillMount() {
        fetch('url')
        .then(response => {
            if (response.ok) {
                return response;
            }else {
                let error = new Error('Error ');
                error.response = response;
                throw error;
            }
            },
            error => {
                let errmess = new Error(error.message);
                throw errmess;
            })
        .then(response => response.text())
        .then(leaders => {
            const str = leaders.substring(76);
            const str2 = str.substring(0, str.length - 9);
            const x = JSON.parse(str2);
            this.setState({ leader: x });

        })
        .catch(error => {
            this.setState({ errMessage: error.message });
        });
        }

        renderall() {           
            return this.state.leader.map(alb => 
              <View style={styles.container} key= {alb.Ref}> 
                <Text style={[styles.textStyle, {marginLeft:'5%'}]}> {alb.Tescil_No}  </Text>

                <Text style={[styles.textStyle, {marginLeft:'6%'}]}> {alb.GumrukAdi}  </Text>

                <Text style={[styles.textStyle, { marginLeft:'5%'}]}> {alb.ACIKLAMA}   </Text>                                                
              </View>
          )
        }

        count(){
            return this.state.leader.map(color => {
                if(color.Renk == 'MAVI'){
                    Blue.push("MAVI");
                }
                else if(color.Renk == 'SARI')
                {
                    Yellow.push("SARI")
                }
            })
        }

    render() {

       this.count();

        console.log(Blue.length);

        console.log(this.state.leader);

        return (

            <View style= {styles.firstView}> 
                 <View style={{flex: 1.5}}>
                     <Header color1 = {Blue.length}  color2 = {Yellow.length}/>
                 </View >
                     <View style={{flex: 0.5, backgroundColor:'#f2f2f2'}}>
                    <Bar />
                    </View>
                <View style={{flex: 9}}>
                    <ScrollView>
                {this.renderall()}
                </ScrollView>
                </View>
                <View style={styles.footerStyle}>
                  <Footer />
                  </View>  
            </View>
        );
}