re-render the whole navigation bar while calling immediatelyResetRouteStack

Summary:
public

Navigator expects that the navigation bar implements the method to refresh itself.
NavigatorNavigationBar already has this method but not for NavigatorBreadcrumbNavigationBar.

Fix diff fixes this with the same fix as D2751922 did.

Reviewed By: wenjingw

Differential Revision: D2914475

fb-gh-sync-id: a2960bad5df3b403bdd2ab1dc4d349d7251b86c8
shipit-source-id: a2960bad5df3b403bdd2ab1dc4d349d7251b86c8
This commit is contained in:
Hedger Wang 2016-02-08 19:51:06 -08:00 committed by facebook-github-bot-8
parent 05e4236b80
commit 7b57b5c84a
1 changed files with 19 additions and 6 deletions

View File

@ -36,6 +36,7 @@ var View = require('View');
var { Map } = require('immutable');
var guid = require('guid');
var invariant = require('invariant');
var Interpolators = NavigatorBreadcrumbNavigationBarStyles.Interpolators;
@ -179,11 +180,7 @@ var NavigatorBreadcrumbNavigationBar = React.createClass({
},
componentWillMount: function() {
this._descriptors = {
crumb: new Map(),
title: new Map(),
right: new Map(),
};
this._reset();
},
render: function() {
@ -192,7 +189,9 @@ var NavigatorBreadcrumbNavigationBar = React.createClass({
var titles = navState.routeStack.map(this._getTitle);
var buttons = navState.routeStack.map(this._getRightButton);
return (
<View style={[styles.breadCrumbContainer, this.props.style]}>
<View
key={this._key}
style={[styles.breadCrumbContainer, this.props.style]}>
{titles}
{icons}
{buttons}
@ -200,6 +199,20 @@ var NavigatorBreadcrumbNavigationBar = React.createClass({
);
},
immediatelyRefresh: function() {
this._reset();
this.forceUpdate();
},
_reset() {
this._key = guid();
this._descriptors = {
crumb: new Map(),
title: new Map(),
right: new Map(),
};
},
_getBreadcrumb: function(route, index) {
if (this._descriptors.crumb.has(route)) {
return this._descriptors.crumb.get(route);