From a2975f473a7409bdf16d06f9d37c8c446ab29f55 Mon Sep 17 00:00:00 2001 From: James Ide Date: Mon, 4 May 2015 19:43:11 -0700 Subject: [PATCH] [Navigator] Pass route into onItemRef The index alone isn't so useful; pass the route as well. (I am using this to implement componentWill/DidFocus in a library instead of onWill/DidFocus). Test Plan: Set up a navigator with a couple of scenes, and see that when onItemRef is called for each one, the route is passed in as the third argument. --- Libraries/CustomComponents/Navigator/Navigator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index c009e8086f10d9..579c7272611e1a 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -253,7 +253,7 @@ var Navigator = React.createClass({ onDidFocus: PropTypes.func, /** - * Will be called with (ref, indexInStack) when the scene ref changes + * Will be called with (ref, indexInStack, route) when the scene ref changes */ onItemRef: PropTypes.func, @@ -1159,13 +1159,13 @@ var Navigator = React.createClass({ return this.state.routeStack; }, - _handleItemRef: function(itemId, ref) { + _handleItemRef: function(itemId, route, ref) { this._itemRefs[itemId] = ref; var itemIndex = this.state.idStack.indexOf(itemId); if (itemIndex === -1) { return; } - this.props.onItemRef && this.props.onItemRef(ref, itemIndex); + this.props.onItemRef && this.props.onItemRef(ref, itemIndex, route); }, _cleanScenesPastIndex: function(index) { @@ -1273,7 +1273,7 @@ var Navigator = React.createClass({ }} style={[styles.baseScene, this.props.sceneStyle, disabledSceneStyle]}> {React.cloneElement(child, { - ref: this._handleItemRef.bind(null, this.state.idStack[i]), + ref: this._handleItemRef.bind(null, this.state.idStack[i], route), })} );