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

72
Views
Update the data from spliced array of object

So, I have splice the data and I want to update it's object from disabled = true to disabled = false .. I have looking for another answer and cant find one..

Any Advice is appreciated. Thank you

this is my dropdown

const newDrop = [
  { key: "1", label: "Monthly GMV", sublabel: "Max.1" },
  { key: "2", label: "AOV", sublabel: "Max.1" },
  { key: "3", label: "Monthly Order", sublabel: "Max.1" },
  { key: "4", label: "Last Purchase", sublabel: "Max.1" },
  { key: "5", label: "Has Purchase" },
  { key: "6", label: "Has Purchase Spesific Product" },
  { key: "7", label: "Located In", sublabel: "Max.1" },
];

selected function : when selected the dropdown, it will add new attribute disabled:true

newInput({ key }) {
    const {
      changeFormAttribute,
      form: { selectedDrop, newDrop, data },
    } = this.props;

    itemIndex = newDrop.map((itm) => {
      let x = itm.key === key;

      return x && itm.key !== "6" && itm.key !== "5" ? { ...itm, disabled: true } : { ...itm };
    });
    
    changeFormAttribute({
      newDrop: itemIndex,
    });
  }

delete function: this is onClick function, when clicked, it should splice the data, and check, if the spliced data have disabled === true change it to disabled:false . the spliced have working properly, but not change the attribute to disabled = false

 deleteInput(index) {
    const {
      changeFormAttribute,
      form: { selectedDrop },
    } = this.props;
  
    let selected = selectedDrop || [];
    selected.splice(index, 1).map((e) => {return e.disabled === true ? false:true })

    changeFormAttribute({ selectedDrop: selected });
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your splice function not returning the element. You may need to change it to


 selected.splice(index, 1).map((e) => {
     e.disabled === true ? false:true
     return e; 
 })
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!