Skip to content

Commit

Permalink
fix for #166, don't pass initial prop to children routers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov authored and Pavlo Aksonov committed Feb 4, 2016
1 parent ef6bfa2 commit aef7e0b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions ExRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ export class ExRouteAdapter {

renderScene(navigator) {
const Component = this.route.component;
const {initial, ...routeProps} = this.route.props;
const child = Component ?
!this.route.wrapRouter ? <Component key={this.route.name} name={this.route.name} {...this.route.props} {...this.props} route={this.route}/>:
<ReactRouter name={this.route.name+"Router"} {...this.route.props} {...this.props} route={this.route} router={ExRouter} initial={"_"+this.route.name} footer={null} header={null}>
<Components.Route {...this.route.props} {...this.props} component={Component} name={"_"+this.route.name} type="push" wrapRouter={false} initial={true}/>
!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}>
<Components.Route {...routeProps} {...this.props} component={Component} name={"_"+this.route.name} type="push" wrapRouter={false} initial={true}/>
</ReactRouter>
:
React.cloneElement(React.Children.only(this.route.children), {...this.route.props, ...this.props, route:this.route});
React.cloneElement(React.Children.only(this.route.children), {...routeProps, ...this.props, route:this.route});

const Header = this.route.header;
const header = Header ? <Header {...this.route.props} {...this.props}/> : null;
const header = Header ? <Header {...routeProps} {...this.props}/> : null;

const Footer = this.route.footer;
const footer = Footer ? <Footer {...this.route.props} {...this.props}/> : null;
const footer = Footer ? <Footer {...routeProps} {...this.props}/> : null;

return (
<View style={styles.transparent}>
Expand Down
2 changes: 1 addition & 1 deletion Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Example extends React.Component {
<Route name="tab5" schema="tab" title="Tab #5" component={TabView} />
</Router>
</Route>
<Route name="launch" header={Header} component={Launch} wrapRouter={true} title="Launch" hideNavBar={true} initial={true}/>
<Route name="launch" header={Header} initial={true} component={Launch} wrapRouter={true} title="Launch" hideNavBar={true}/>
</Router>
);
}
Expand Down
2 changes: 1 addition & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"dependencies": {
"react-native": "^0.17",
"react-native-button": "^1.2.1",
"react-native-router-flux": "^2.1.3"
"react-native-router-flux": "^2.1.5"
}
}

0 comments on commit aef7e0b

Please sign in to comment.