opened
Andreyco
username_0
Add support for `valueLink` prop, which will handle setting and getting of value.  
This would serve as alternative to `value` and `onChange` props.
Add support for valueLink
issue
created
appsciences
username_1
This can be achieved via inputProps attribute, e.g.

    <Select
        options={[
            ...
        ]}
        
        inputProps={{valueLink:this.props.getLinkState("fieldName")}}
    />
comment
created
pindia
username_2
The above solution didn't work for me, I got a "Cannot provide a valueLink and a value or onChange event" error. (No, I didn't pass value or onChange; presumably `react-select` is automatically doing so)

I ended up writing a wrapper around the component instead. It supports both the old way and `valueLink` for both single and multi selects:

```jsx
var Select = require('react-select');

module.exports.Select = React.createClass({
  onChange(textValue, arrayValue) {
    // Dispatch to caller onChange if present
    if(this.props.onChange)
      this.props.onChange(textValue, arrayValue);
    if(this.props.valueLink){
      // Multi select: grab values and send array of values to valueLink
      if(this.props.multi)
        this.props.valueLink.requestChange(_.pluck(arrayValue, 'value'));
      // Single select: send text value to valueLink
      else
        this.props.valueLink.requestChange(textValue);
    }
  },
  render() {
    // Prevent specific props from being passed through so we can override them
    var { valueLink, value, onChange, ...other } = this.props;
    return <Select value={value || valueLink.value} onChange={this.onChange} {...other} />
  }
});
```
comment
created
appsciences
username_1
Pindia, you are absolutely right, it's my mistake (didn't recompile the project when trying this). I've updated my comment.
comment
closed
jossmac
username_3
issue