Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Update SegmentedControlIOS.ios.js
Browse files Browse the repository at this point in the history
Summary:Updating the comments to clarify that the selectedIndex prop is not just for pre-selecting an index, but that it can also be used to programmatically change the value of the selected index.
Closes facebook#6519

Differential Revision: D3075199

Pulled By: mkonicek

fb-gh-sync-id: 8ce336ad491bb2fed13df15ebddb1b24535c50ff
shipit-source-id: 8ce336ad491bb2fed13df15ebddb1b24535c50ff
  • Loading branch information
pedramsaleh authored and Facebook Github Bot 7 committed Mar 21, 2016
1 parent f1a0695 commit b85f0ac
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ type Event = Object;

/**
* Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
*
* #### Programmatically changing selected index
*
* The selected index can be changed on the fly by assigning the
* selectIndex prop to a state variable, then changing that variable.
* Note that the state variable would need to be updated as the user
* selects a value and changes the index, as shown in the example below.
*
* ````
* <SegmentedControlIOS
* values={['One', 'Two']}
* selectedIndex={this.state.selectedIndex}
* onChange={(event) => {
* this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
* }}
* />
* ````
*/
var SegmentedControlIOS = React.createClass({
mixins: [NativeMethodsMixin],
Expand All @@ -43,7 +60,7 @@ var SegmentedControlIOS = React.createClass({
values: PropTypes.arrayOf(PropTypes.string),

/**
* The index in `props.values` of the segment to be pre-selected
* The index in `props.values` of the segment to be (pre)selected.
*/
selectedIndex: PropTypes.number,

Expand Down

0 comments on commit b85f0ac

Please sign in to comment.