immediatelyResetRouteStack does not update Navigator's title

Summary:
re-render the whole navigation bar while calling immediatelyResetRouteStack
from navigator.

Reviewed By: zjj010104

Differential Revision: D2751922

fb-gh-sync-id: 79bcd1457a96eaf3ca94b81da9bfecbec7f8af46
This commit is contained in:
Hedger Wang 2015-12-15 15:38:43 -08:00 committed by facebook-github-bot-7
parent e39657aaae
commit 67c6afd14b
2 changed files with 21 additions and 4 deletions

View File

@ -375,6 +375,7 @@ var Navigator = React.createClass({
transitionQueue: [],
}, () => {
this._handleSpringUpdate();
this._navBar && this._navBar.immediatelyRefresh();
});
},

View File

@ -33,6 +33,8 @@ var Platform = require('Platform');
var StyleSheet = require('StyleSheet');
var View = require('View');
var guid = require('guid');
var { Map } = require('immutable');
var COMPONENT_NAMES = ['Title', 'LeftButton', 'RightButton'];
@ -78,6 +80,21 @@ var NavigatorNavigationBar = React.createClass({
},
componentWillMount: function() {
this._reset();
},
/**
* Stop transtion, immediately resets the cached state and re-render the
* whole view.
*/
immediatelyRefresh() {
this._reset();
this.forceUpdate();
},
_reset() {
this._key = guid();
this._reusableProps = {};
this._components = {};
this._descriptors = {};
@ -91,9 +108,6 @@ var NavigatorNavigationBar = React.createClass({
/*string*/componentName,
/*number*/index
) /*object*/ {
if (!this._reusableProps) {
this._reusableProps = {};
}
var propStack = this._reusableProps[componentName];
if (!propStack) {
propStack = this._reusableProps[componentName] = [];
@ -160,7 +174,9 @@ var NavigatorNavigationBar = React.createClass({
);
return (
<View style={[styles.navBarContainer, navBarStyle, this.props.style]}>
<View
key={this._key}
style={[styles.navBarContainer, navBarStyle, this.props.style]}>
{components}
</View>
);