Skip to content

Commit

Permalink
Fixes error when navigationBar is set back to null
Browse files Browse the repository at this point in the history
Summary:
This fixes a regression introduced in df70005

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 #4941

Reviewed By: svcscm

Differential Revision: D2788889

Pulled By: bestander

fb-gh-sync-id: f8f1cd6cc2ce13b1b1b86fa76d3b22c26a8adb5b
  • Loading branch information
gre authored and Martin Konicek committed Jan 18, 2016
1 parent d623fda commit 0b63571
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Libraries/CustomComponents/Navigator/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b63571

Please sign in to comment.