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

307
Views
How to use React Select if the object properties's are not value and label?
import { Fragment, useState } from "react";
import Select from 'react-select';

let items = [
    {
        item: 1,
        name: "tv"
    },
    {
        item: 2,
        name: "PC"
    }
]

const Home = () => {
    const [selectedValue, setSelectedValue] = useState(6)

    const handleChange = obj => {
        setSelectedValue(obj.item)
    }

    return (
        <Fragment>
            <div>Home page</div>

            <p>Test React Select...</p>
            <Select
                value={items.find(x => x.item === selectedValue)}
                options={items}
                onChange={handleChange}
            />

            <p>selected Value:...</p>
            {selectedValue}

        </Fragment>
    )
}
export default Home;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can pass the mapped array to "options" property:

options={items.map(({item, name}) => ({value: name, label: item}))}
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!