Skip to content

for SegmentedControlIOS component,onChange(event),event.nativeEvent =null #1310

@donghanji

Description

@donghanji

for SegmentedControlIOS component,when used onChange event,the callback param event,event.nativeEvent is null,no selectedIndex attribute.

var EventSegmentedControlExample=React.createClass({
  getInitialState(){
    return {
      values:['One','Two','Three'],
      value:'Not selected',
      selectedIndex:undefined
    };
  },
  render(){
    return(
      <View>
        <Text style={styles.text}>
          Value:{this.state.value}
        </Text>
        <Text style={styles.text}>
          Index:{this.state.selectedIndex}
        </Text>
        <SegmentedControlIOS
          values={this.state.values}
          selectedIndex={this.state.selectedIndex}
          onChange={this._onChange}
          onValueChange={this._onValueChange}
        />
      </View>
    );
  },
_onChange(event){
    console.log(event);//debug console log here
    this.setState({
      selectedIndex:event.nativeEvent.selectedIndex
    });
  },
  _onValueChange(value){
    this.setState({
      value:value
    });
  }
});

//render EventSegmentedControlExample
//

this is console log:

_dispatchIDs: null,
_dispatchListeners: null,
bubbles: nullcancelable: null,
currentTarget: null,
defaultPrevented: null,
dispatchConfig: null,
dispatchMarker: null,
eventPhase: null,
isDefaultPrevented: function () {},
isPropagationStopped: function () {},
isTrusted: null,
nativeEvent: null,//there is null
target: null,
timeStamp: null,
type: null

the SegmentedControlIOS is a new component,is this an bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions