I'm new to React Native and ES6, but know a little about JS and I'm having difficulty finding out what the following code means. I know what it does and I can identify bits of it, but not everything.
static navigationOptions = ({ navigation }) => {
if (navigation.state.params == undefined )
{
return {
headerTitle: <Text></Text>,
headerLeft: null
}
}
else
{
return {
headerTitle: navigation.state.params.toolbarComponent,
headerLeft: null
};
}
};
Now I know about the arrow function, that's fine, but I'm really confused about where the navigation variable is coming from. If I remove the braces so the first line looks like this:
static navigationOptions = ({ navigation }) => {
Then the code complains about prop not existing, so I assume this uses a bind on navigation.
So really what I can't work out is where navigation is coming from, i.e. in another example somewhere else how will I know what the variable name is called. And if you can confirm what the braces do around the variable navigation then I would appreciate it. I suspect this is really an ES6 question.