Fixes error when navigationBar is set back to null

Summary:
This fixes a regression introduced in df70005c12

If you set navigationBar props (on Navigator) and then later set it back to null, it will crashes.
(N.B. this should be possible as navigationBar is optional)

cc satya164
Closes https://github.com/facebook/react-native/pull/4941

Reviewed By: svcscm

Differential Revision: D2788889

Pulled By: bestander

fb-gh-sync-id: f8f1cd6cc2ce13b1b1b86fa76d3b22c26a8adb5b
This commit is contained in:
Gaëtan Renaudeau 2016-01-07 05:24:32 -08:00 committed by facebook-github-bot-3
parent ac72611bb1
commit 4f9086f0e7
1 changed files with 6 additions and 3 deletions

View File

@ -1084,13 +1084,16 @@ var Navigator = React.createClass({
},
_renderNavigationBar: function() {
if (!this.props.navigationBar) {
let { navigationBar } = this.props;
if (!navigationBar) {
return null;
}
return React.cloneElement(this.props.navigationBar, {
return React.cloneElement(navigationBar, {
ref: (navBar) => {
this.props.navigationBar.ref instanceof Function && this.props.navigationBar.ref(navBar);
this._navBar = navBar;
if (navigationBar && typeof navigationBar.ref === 'function') {
navigationBar.ref(navBar);
}
},
navigator: this._navigationBarNavigator,
navState: this.state,