import Select from 'react-select';
const Home = () => {
const animals = [
{ label: 'cat', value: 'cat' },
{ label: 'dog', value: 'dog' },
{ label: 'lion', value: 'lion' },
{ label: 'eagle', value: 'eagle' },
]
}
return (
<>
<Select
name="animals"
options={animals}
strong text**isMulti
onChange={(e) => console.log(e.target.name)}
/>
</>
)
**in console when i select some item it will give me this error
cannot read property of undefined (reading 'name') at onChange
Because it will return an array of object(s) {label: '', value: ''}
rather than an event
object.
<Select
name="animals"
options={animals}
isMulti
onChange={(value, actionMeta) => console.log(actionMeta.name)}
/>