Reputation: 9407
I have this transition of screens:
A -> B -> C
Now on B, I have this static navigationOptions
:
class ScreenB extends Component {
static navigationOptions = ({navigation}) => ({
/* works fine to display props here -> */ title: navigation.state.params.MyString, // works fine for display
headerLeft: <Button title="<" onPress={() => navigation.goBack()} />,
/* does not work to pass it here -> */ headerRight: <Button title="+" onPress={() => navigation.navigate('ScreenC', {navigation.state.params.MyString})} />
} );
// ...
}
I receive MyString
from A
, and display it fine in B
. But I would like to pass it to C
on headerRight
button click. A syntax error on its definition says:
Unexpected token, expected ,
What would be the issue? Thanks
Upvotes: 0
Views: 90
Reputation: 110
Change this line:
headerRight: <Button title="+" onPress={() => navigation.navigate('ScreenC', {navigation.state.params.MyString})} />
For:
headerRight: <Button title="+" onPress={() => navigation.navigate('ScreenC', {title:navigation.state.params.MyString})} />
You are missing the key.
Upvotes: 1