Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How to get name attribute of a react-select using event.target.name
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

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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)} 
 />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!