Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
How can disable only specific items in an array using their ID's?
if(event. value = "Network") {
  var opt = this. state. exportcontent
  for(conditions to be written)
  {
    condition to be written .disable= true;
  }
}

Here Network is the option that I selected through the event. export content is an array that consists of six items. I only want 1,4 and 6 id's and their values to be enabled for Network. How can I write the condition using for loop in react?

And the rest of the options should get all the 6 ids and values from export content.

I am new to React so I am expecting the values to be shown on my page.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

    var arr =  [
             {
             "customerId": 0,
             "name":"JIO",
             "isDisable": false
            },
            {
            "customerId": 1,
            "name":"ABC",
            "isDisable": false
            },
            {
            "customerId": 2,
             "name":"PQR",
            "isDisable": false
            },
            {
           "customerId": 3,
           "name":"XYZ",
           "isDisable": false
           },
          {
           "customerId": 4,
           "name":"TYE",
           "isDisable": false
           },
           {
           "customerId": 5,
           "name":"PEI",
           "isDisable": false
           },
          ];
       
   const ids = [0,3,5]; 
   const result = arr.map((obj) => {
        if(ids.includes(obj.customerId)){
          obj.isDisable = true;
      }
      return obj;
    })
    
    
console.log(result);

var arr =  [
        {
        "customerId": 1,
        "name":"ABC",
        "isDisable": false
        },
        {
        "customerId": 2,
         "name":"PQR",
        "isDisable": false
        }
      ]
   
   
arr = arr.map((obj) => {
 if(obj.customerId === 1) {
   obj.isDisable = true;
 } 
 return obj;
})

console.log(arr);

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda