Update SegmentedControlIOS.ios.js

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 https://github.com/facebook/react-native/pull/6519

Differential Revision: D3075199

Pulled By: mkonicek

fb-gh-sync-id: 8ce336ad491bb2fed13df15ebddb1b24535c50ff
shipit-source-id: 8ce336ad491bb2fed13df15ebddb1b24535c50ff
This commit is contained in:
pedramsaleh 2016-03-20 18:06:33 -07:00 коммит произвёл Facebook Github Bot 7
Родитель f1a0695c7d
Коммит b85f0ac74f
1 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -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],
@ -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,