react native how to pass props through navigator to another Activity/View -
it seems simple solution (as intuitively me), couldn't find working solution.
here 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 how i'm passing props:
this.props.navigator.push({title: 'mainactivity', component:mainactivity, gamekey:key, passprops:{title:'bla'}});
here mainactivity want props.
i've tried:
this.props.route.gamekey, this.route.gamekey, this.props.gamekey
neither worked, understand may should pass props through renderscene, other way. may passing route through createelement?
please help.
the problem more serious, because i've passed props 1 activity other via navigator.
so, solution pass every time u need (from activity any) using in
return react.createelement(route.component, {navigator, route});
thanks @stereodenis.
after push in activity: this.props.navigator.push({title: 'mainactivity', component:mainactivity, gamekey:key, passprops:{title:'bla'}});
and access them via: this.props.route.gamekey
to make totally clear - route accessible, because of passed {navigator, route} in createelement every time u push, yet prop.
the renderscene of navigator component should be:
{ title, gamekey, passprops } = route; return react.createelement(route.component, { navigator, title, gamekey, passprops })
Comments
Post a Comment