It seems like simple solution (as it was intuitively for me), but I couldn't find any working solution.
Here is my Navigator - render method code:
render() {
return (
<Navigator initialRoute={{title:'Games', component:Games}}
configureScene={() => {
return Navigator.SceneConfigs.FloatFromRight;
}}
renderScene={(route, navigator) =>
{
if (route.component) {
return React.createElement(route.component, {navigator});
}
}
} />
);
}
Here is how I'm passing props:
this.props.navigator.push({title: 'MainActivity', component:MainActivity, gameKey:key, passProps:{title:'bla'}});
Here is a MainActivity where I want to get those props.
I've tried:
this.props.route.gameKey,
this.route.gameKey,
this.props.gameKey
neither worked, I understand that may be I should pass those props specifically through renderScene, the other way. May be passing route through createElement?
Please help.
The problem was more serious, because I've passed props from one activity to the other via Navigator.
So, the solution to pass every time anything U need (from any activity to any) is using in
return React.createElement(route.component, {navigator, route});
Thanks to @stereodenis.
After push like this in any activity: this.props.navigator.push({title: 'MainActivity', component:MainActivity, gameKey:key, passProps:{title:'bla'}});
And then access them via: this.props.route.gameKey
To make it totally clear - route is now accessible, because of passed {navigator, route} in createElement every time U push, so this is yet another prop.