Reputation: 4883
I'm using StackNavigator
, I have added button in the toolbar, and when clicking that button, I want to navigate to another screen, instead of that, when I press button, I get an error:
"Can't find variable navigate"
. How to fix that?
static navigationOptions = {
title: 'Review Jobs',
headerRight: <Button tittle="Settings" onPress={()=> navigate('settings') } />
}
Upvotes: 0
Views: 110
Reputation: 24680
If you are trying to use methods from navigation while setting navigationOptions
you can use an arrow function rather than just setting it as a plain object
Example
static navigationOptions = ({navigation}) => ({
title: 'Review Jobs',
headerRight: <Button tittle="Settings" onPress={()=> navigation.navigate('settings') } />
});
Upvotes: 2
Reputation: 358
The right syntax would be
static navigationOptions = ({ navigation }) => ({
title: 'Review Jobs',
headerRight: <Button tittle="Settings" onPress={()=> navigation.navigate('settings') } />
});
Upvotes: 3