I am trying to navigate to another screen using react-navigation. However with this code I get the error: undefined is not an object (evaluation 'this.props.navigation')
When invoking navigatedirectly (see example at the bottom) it works.
What am I doing wrong?
This does not work:
_renderRow (rowData) {
return (
<View >
<TouchableHighlight onPress={this._handlePress} underlayColor='white'>
<Image
style={{width: 50, height: 50}}
source={{uri: 'http://openweathermap.org/img/w/' + rowData.iconName + '.png'}}
/>
</TouchableHighlight>
</View>
)
}
_handlePress () {
this.props.navigation.navigate('Details')
}
This does work:
_renderRow (rowData) {
return (
<View >
<TouchableHighlight onPress={() => this.props.navigation.navigate('Details')} underlayColor='white'>
<Image
style={{width: 50, height: 50}}
source={{uri: 'http://openweathermap.org/img/w/' + rowData.iconName + '.png'}}
/>
</TouchableHighlight>
</View>
)
}
onPress={this._handlePress.bind(this)}