Skip to content

Commit

Permalink
pass router props to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov authored and Pavlo Aksonov committed Feb 10, 2016
1 parent dd36724 commit 2724b81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions ExRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class ExRouteAdapter {
renderScene(navigator) {
const Component = this.route.component;
const {initial, ...routeProps} = this.route.props;
debug("RENDER SCENE"+this.props.dispatch);
const child = Component ?
!this.route.wrapRouter ? <Component key={this.route.name} name={this.route.name} {...routeProps} {...this.props} route={this.route}/>:
<ReactRouter name={this.route.name+"Router"} {...routeProps} {...this.props} route={this.route} router={ExRouter} initial={"_"+this.route.name} footer={null} header={null}>
Expand Down Expand Up @@ -198,7 +199,7 @@ export default class ExRouter extends React.Component {
return false;
}
}
this.refs.nav.push(new ExRouteAdapter(route, props));
this.refs.nav.push(new ExRouteAdapter(route, {...this.props, ...props}));
debug("PUSHED TO:"+route.name);
return true;
}
Expand All @@ -212,7 +213,7 @@ export default class ExRouter extends React.Component {
}
//this.refs.nav.immediatelyResetRouteStack(this.refs.nav.getCurrentRoutes().splice(-1,1));
//this.refs.nav.push(new ExRouteAdapter(route, props));
this.refs.nav.replace(new ExRouteAdapter(route, props));
this.refs.nav.replace(new ExRouteAdapter(route, {...this.props, ...props}));
return true;
}

Expand All @@ -228,7 +229,7 @@ export default class ExRouter extends React.Component {
return false;
}
}
this.refs.nav.immediatelyResetRouteStack([new ExRouteAdapter(route, props)]);
this.refs.nav.immediatelyResetRouteStack([new ExRouteAdapter(route, {...this.props, ...props})]);
return true;
}

Expand All @@ -245,7 +246,7 @@ export default class ExRouter extends React.Component {
if (exist.length){
navigator.jumpTo(exist[0]);
} else {
navigator.push(new ExRouteAdapter(route, props));
navigator.push(new ExRouteAdapter(route, {...this.props, ...props}));

}
this.setState({selected: route.name});
Expand Down Expand Up @@ -290,9 +291,7 @@ export default class ExRouter extends React.Component {
<ExNavigator
ref="nav"
initialRouteStack={router.stack.map(route => {
const oldProps = router.routes[route].props
router.routes[route].props = {...oldProps, ...this.props}
return new ExRouteAdapter(router.routes[route])
return new ExRouteAdapter(router.routes[route], this.props)
})}
style={styles.transparent}
sceneStyle={{ paddingTop: 0, backgroundColor:'transparent' }}
Expand Down
2 changes: 1 addition & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"react-native": "^0.19",
"react-native-button": "^1.2.1",
"react-native-router-flux": "^2.2.0",
"react-native-router-flux": "^2.2.1",
"react-redux": "^4.4.0",
"redux": "^3.3.1"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-router-flux",
"version": "2.2.0",
"version": "2.2.1",
"description": "React Native Router using Flux architecture",
"repository": {
"type": "git",
Expand Down

0 comments on commit 2724b81

Please sign in to comment.