When the header is click, I want it navigate to next page. However, I do not know how to access navigation props outside the class. Any suggestion on how to do this?
import React,{Component} from 'react'
import { View, Text, TouchableOpacity, FlatList} from 'react-native'
class header extends Component {
render(){
return(
<TouchableOpacity
onPress={() => **this.props.navigation.navigate('PageTwo')**}
>
<Text>{'Go to next Page Two'}</Text>
</TouchableOpacity>
)
}
}
export default class PageOne extends Component {
static navigationOptions = {
title: 'Page One',
}
constructor(props) {
super(props);
this.state = {
data: // ...
};
}
_renderItem = ({item}) => (
// ...
);
render(){
return(
<FlatList
ListHeaderComponent={header}
data={this.state.data}
renderItem={this._renderItem}
/>
)
}
}