React-select: How to pass multiple parameters in onChange

Created on 23 Jan 2017  路  2Comments  路  Source: JedWatson/react-select

How to pass multiple parameters in onChange method, by default it pass only the value.

I am working with redux form and creating a nested selected options.

Thanks :)

Most helpful comment

Hi, you can do something like:

function onChange(id)  {
    const _onChange = (val) => {
        console.log(`id: ${id}, new value: ${val}`);
    }
    return _onChange; // you can also do return _onChange.bind(this) if you need the scope.
}

then pass the result of the onChange function into the onChange prop of select:
<Select onChange={onChange("hello world")} />

All 2 comments

Hi, you can do something like:

function onChange(id)  {
    const _onChange = (val) => {
        console.log(`id: ${id}, new value: ${val}`);
    }
    return _onChange; // you can also do return _onChange.bind(this) if you need the scope.
}

then pass the result of the onChange function into the onChange prop of select:
<Select onChange={onChange("hello world")} />

Hello -

In an effort to sustain the react-select project going forward, we're closing old issues / pull requests.

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.

If you feel this issue / pull request is still relevant and you'd like us to review it, please leave a comment and we'll do our best to get back to you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

geraldfullam picture geraldfullam  路  3Comments

coder-guy22296 picture coder-guy22296  路  3Comments

pashap picture pashap  路  3Comments

batusai513 picture batusai513  路  3Comments

x-yuri picture x-yuri  路  3Comments