[ReactNative] Fix Navigator resetTo

This commit is contained in:
Eric Vicenti 2015-04-27 17:23:19 -07:00
parent b6e6dae6ba
commit 6749f88650
1 changed files with 5 additions and 3 deletions

View File

@ -957,7 +957,7 @@ var Navigator = React.createClass({
* `index` specifies the route in the stack that should be replaced. * `index` specifies the route in the stack that should be replaced.
* If it's negative, it counts from the back. * If it's negative, it counts from the back.
*/ */
replaceAtIndex: function(route, index) { replaceAtIndex: function(route, index, cb) {
invariant(!!route, 'Must supply route to replace'); invariant(!!route, 'Must supply route to replace');
if (index < 0) { if (index < 0) {
index += this.state.routeStack.length; index += this.state.routeStack.length;
@ -988,6 +988,7 @@ var Navigator = React.createClass({
this._emitWillFocus(route); this._emitWillFocus(route);
this._emitDidFocus(route); this._emitDidFocus(route);
} }
cb && cb();
}); });
}, },
@ -1034,8 +1035,9 @@ var Navigator = React.createClass({
resetTo: function(route) { resetTo: function(route) {
invariant(!!route, 'Must supply route to push'); invariant(!!route, 'Must supply route to push');
if (this._canNavigate()) { if (this._canNavigate()) {
this.replaceAtIndex(route, 0); this.replaceAtIndex(route, 0, () => {
this.popToRoute(route); this.popToRoute(route);
});
} }
}, },