Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion components/NavBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var NavBarContainer = React.createClass({
},

componentWillReceiveProps: function(newProps) {
let previousRoute;

if (!this.props.currentRoute || (this.props.currentRoute.index === null)) {
newProps.currentRoute.index = 0;
}
Expand All @@ -26,8 +28,12 @@ var NavBarContainer = React.createClass({
return;
}

if (!this.props.currentRoute || newProps.currentRoute.index !== this.props.currentRoute.index) {
previousRoute = this.props.currentRoute;
}

this.setState({
previousRoute: this.props.currentRoute,
previousRoute: previousRoute,
currentRoute: newProps.currentRoute
});
},
Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ var Router = React.createClass({
navigator.popToTop();
};

var goToRouteAndReset = function(route) {
var routeState = Object.assign({}, this.state.route, { index: 0 });
this.setState({ route: routeState });
navigator.resetTo(route);
}.bind(this);

var didStartDrag = function(evt) {
var x = evt.nativeEvent.pageX;
if (x < 28) {
Expand Down Expand Up @@ -89,7 +95,7 @@ var Router = React.createClass({
var updateNavbarProps = function(props) {
route.updateNavbarProps && route.updateNavbarProps(props);
route.updateStaticNavbarProps && route.updateStaticNavbarProps(props);
}
};

var Content = route.component;
return (
Expand All @@ -104,6 +110,7 @@ var Router = React.createClass({
push:goForward,
pop:goBackwards,
popToTop:goToFirstRoute,
reset:goToRouteAndReset,
}}
updateBarBackgroundStyle={
(style)=>{
Expand Down Expand Up @@ -156,4 +163,4 @@ var styles = StyleSheet.create({
});


module.exports = Router;
module.exports = Router;