Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

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

Reviewed By: svcscm

Differential Revision: D2788889

Pulled By: bestander

fb-gh-sync-id: f8f1cd6cc2ce13b1b1b86fa76d3b22c26a8adb5b
  • Loading branch information
gre authored and csudanthi committed Jan 16, 2016
1 parent bb6dc1c commit c762e4c
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 c762e4c

Please sign in to comment.