Skip to content
Permalink
Browse files

calling navigationBar's overridden ref function

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 df70005c12e3be14bfbdf0b32f9ea0a5c052deba
Showing with 4 additions and 1 deletion.
  1. +4 −1 Libraries/CustomComponents/Navigator/Navigator.js
@@ -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,
});

7 comments on commit df70005

@gre

This comment has been minimized.

Copy link
Contributor

replied Dec 23, 2015

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

This comment has been minimized.

Copy link
Collaborator

replied Dec 23, 2015

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

@gre

This comment has been minimized.

Copy link
Contributor

replied Dec 23, 2015

I have, working on it

@satya164

This comment has been minimized.

Copy link
Collaborator

replied Dec 23, 2015

@gre Awesome. Thanks.

@gre

This comment has been minimized.

Copy link
Contributor

replied Dec 23, 2015

@despairblue

This comment has been minimized.

Copy link
Contributor Author

replied Dec 23, 2015

👍

@yamill

This comment has been minimized.

Copy link
Contributor

replied Dec 23, 2015

You are a life saver.

Please sign in to comment.
You can’t perform that action at this time.