Amio.io
Amio.io

Reputation: 21575

React-bootstrap: onChange invoked only once for "select"

Here is a fiddle with the example demonstrating this code:

render: function() {
    return (
      <FormControl componentClass="select" onChange={console.log("changed")}>
                    <option value="1">A</option>         
                    <option value="2">B</option>         
      </FormControl>                       
    );
  }

onChange() is invoked only when my component gets rendered.

I want to react on a different option. So if I change 'A' to 'B' I want the component to fire onChange() event. What am I missing?

Upvotes: 1

Views: 1182

Answers (1)

Tugrul
Tugrul

Reputation: 1808

Write a method named handleSelectChange

handleSelectChange: function(event) {
    //Do sth
}

and call it like onChange={this.handleSelectChange}

Upvotes: 1

Related Questions