Skip to content

Commit

Permalink
calling navigationBar's overridden ref function
Browse files Browse the repository at this point in the history
Summary: Before that it was not possible to get a ref to a navigation bar (unless using Navigator's internal `_navBar` prop)
Closes #3755

Reviewed By: svcscm

Differential Revision: D2674315

Pulled By: nicklockwood

fb-gh-sync-id: 26120f7bcbb675e8217b8bd963dcc6ed314d4ba3
  • Loading branch information
despairblue authored and facebook-github-bot-4 committed Nov 30, 2015
1 parent 0f0b578 commit df70005
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/CustomComponents/Navigator/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,10 @@ var Navigator = React.createClass({
return null;
}
return React.cloneElement(this.props.navigationBar, {
ref: (navBar) => { this._navBar = navBar; },
ref: (navBar) => {
this.props.navigationBar.ref instanceof Function && this.props.navigationBar.ref(navBar);
this._navBar = navBar;
},
navigator: this._navigationBarNavigator,
navState: this.state,
});
Expand Down

7 comments on commit df70005

@gre
Copy link
Contributor

@gre gre commented on df70005 Dec 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit introduces a regression:

the ref function is called asynchronously, at this time, this.props.navigationBar might be null, this will cause a runtime error

@satya164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gre Do you've a solution in mind? If yes, can you send a PR?

@gre
Copy link
Contributor

@gre gre commented on df70005 Dec 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have, working on it

@satya164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gre Awesome. Thanks.

@gre
Copy link
Contributor

@gre gre commented on df70005 Dec 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@despairblue
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yamill
Copy link
Contributor

@yamill yamill commented on df70005 Dec 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are a life saver.

Please sign in to comment.