Skip to content

Commit

Permalink
don't pass reserved props
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 2724b81 commit 370b559
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions ExRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import ReactRouter from './ReactRouter';
import Actions from './Actions';
import debug from './debug';

function parentProps(props = {}){
const {name, sceneConfig, title, children, router, initial, showNavigationBar, hideNavBar, footer, header, ...routerProps} = props;
return routerProps;

}
export class ExRouteAdapter {
name: string;
navigator: ExNavigator;
Expand Down Expand Up @@ -48,7 +53,6 @@ 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 @@ -199,21 +203,21 @@ export default class ExRouter extends React.Component {
return false;
}
}
this.refs.nav.push(new ExRouteAdapter(route, {...this.props, ...props}));
this.refs.nav.push(new ExRouteAdapter(route, {...props, ...parentProps(this.props)}));
debug("PUSHED TO:"+route.name);
return true;
}

onReplace(route: Route, props:{ [key: string]: any}):boolean {
if (this.props.onReplace){
const res = this.props.onReplace(route, props);
const res = this.props.onReplace(route, {...props, ...parentProps(this.props)});
if (!res){
return false;
}
}
//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, {...this.props, ...props}));
this.refs.nav.replace(new ExRouteAdapter(route, {...props, ...parentProps(this.props)}));
return true;
}

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

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

}
this.setState({selected: route.name});
Expand Down Expand Up @@ -284,18 +288,14 @@ export default class ExRouter extends React.Component {

const Footer = this.props.footer;
const footer = Footer ? <Footer {...this.props} {...this.state}/> : null;
debug("RENDER ROUTER:",router.name);
debug("RENDER ROUTER:"+router.name);
return (
<View style={styles.transparent}>
{header}
<ExNavigator
ref="nav"
initialRouteStack={router.stack.map(route => {
return new ExRouteAdapter(router.routes[route], this.props)
})}
style={styles.transparent}
sceneStyle={{ paddingTop: 0, backgroundColor:'transparent' }}
renderNavigationBar={props=><ExNavigationBar {...props} router={router}/>}
<ExNavigator ref="nav" initialRouteStack={router.stack.map(route => new ExRouteAdapter(router.routes[route], parentProps(this.props)))}
style={styles.transparent}
sceneStyle={{ paddingTop: 0, backgroundColor:'transparent' }}
renderNavigationBar={props=><ExNavigationBar {...props} router={router}/>}
{...this.props}
/>
{footer}
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.1",
"react-native-router-flux": "^2.2.2",
"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.1",
"version": "2.2.2",
"description": "React Native Router using Flux architecture",
"repository": {
"type": "git",
Expand Down

0 comments on commit 370b559

Please sign in to comment.