Skip to content

Commit

Permalink
Add position to Picker onValueChange's call
Browse files Browse the repository at this point in the history
Summary:According to the [docs](http://facebook.github.io/react-native/releases/0.20/docs/picker.html#onvaluechange), `Picker`'s `onValueChange` should be called with `itemValue` and `itemPosition` but currently only `itemValue` is passed. This PR fixes that.
The position is passed as the 2nd parameter to not introduce any breaking change, and also to respect the current documentation.
The documentation doesn't need to be changed as it will be correct with this PR, but maybe it needs to be updated until this is merged?
Closes #5874

Differential Revision: D2953936

Pulled By: nicklockwood

fb-gh-sync-id: b8c1283013d4c7ed315066d8750f601f76f6bbb2
shipit-source-id: b8c1283013d4c7ed315066d8750f601f76f6bbb2
  • Loading branch information
Bhullnatik authored and facebook-github-bot-7 committed Feb 19, 2016
1 parent f961b78 commit b454d31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ var PickerAndroid = React.createClass({
var position = event.nativeEvent.position;
if (position >= 0) {
var value = this.props.children[position].props.value;
this.props.onValueChange(value);
this.props.onValueChange(value, position);
} else {
this.props.onValueChange(null);
this.props.onValueChange(null, position);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var PickerIOS = React.createClass({
});
return {selectedIndex, items};
},

render: function() {
return (
<View style={this.props.style}>
Expand All @@ -74,7 +74,7 @@ var PickerIOS = React.createClass({
this.props.onChange(event);
}
if (this.props.onValueChange) {
this.props.onValueChange(event.nativeEvent.newValue);
this.props.onValueChange(event.nativeEvent.newValue, event.nativeEvent.newIndex);
}

// The picker is a controlled component. This means we expect the
Expand Down

0 comments on commit b454d31

Please sign in to comment.