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

184
Views
Need to Replace the Object key name to another name and Pass down to dropdown list using React

I want to Replace the Object Key name "Value" to "label" and Pass down to DropdownList.. For Example, I am Using "item.value" in the Dropdown Component, But now I need to get the Inputs Data and replace "item.value" to "item.label"... So How Can I change that Object Key name and render the List in DropDown Can Anyone help in this, Thanks in Advance

export const inputs = {
    "purpose": [
         {
            "locale": "er",
             "code": "zzz",
             "value": "Payment"
         },
         {
            "locale": "po",
             "code": "dgf",
             "value": "Support"
         },
         {
            "locale": "fg",
             "code": "oiuy",
             "value": "yes Worked"
         },

Here is the Dropdown

const Dropdown = () => {
    const data = inputs;
    //console.log(data.purpose);
    return (
                <select >
                    <option>Select an Option</option>
                    {data.purpose.map((items)=>(
                           //console.log(items.value);
                           <option>{items.value}</option>
                    ))}
                </select>
            </div>
        </div>
    )
}

export default Dropdown
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can make a copy of the array with new keys by mapping through it as:

const transformed = inputs.purpose.map(({ locale, code , value }) => ({ label: value, locale: locale, code : code}));
about 4 years ago · Juan Pablo Isaza Report

0

easy way :

const new=inputs.purpose.map(i=>{
    const temp={};
    temp.locale=i.locale;
    temp.code=i.code;
    temp.label=i.value;
    return temp;
    })
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!