chymtt / ReactNativeDropdownAndroid

A simple wrapper for Android's Spinner in react-native
MIT License
61 stars 22 forks source link

onchange call to a function #10

Closed zichaolim closed 8 years ago

zichaolim commented 8 years ago

how to call to a function when it trigger onChange ? Please provide an example. Thanks.

chymtt commented 8 years ago

This is basic operation for react in general, I recommend reading more tutorials on reactjs. Anyway here's a advanced use case example:

class TestComponent extends React.Component {
  constructor() {
    super();
    this.onChange = this._onChange.bind(this);
  }
  _onChange(data) {
    // Your function goes here
    console.log(data);
  }
  render() {
    return (
      <Dropdown
        style={{ height: 20, width: 200}}
        ...
        onChange={this.onChange} />
    );
  }
}