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

327
Visualizações
React JS, how can I disable an individual button in a mapped list?

New to react, I currently have a list of buttons mapped based off an api response like so:

render() { 
  return(
      <div> 
        <h4>User Status:</h4> 
        <div className='buttonContainer'>
        {this.state.data.map((status =>   
            <li key={status.key}>
              <button id={status.key} value = {status.text} onClick={this.nextStep}/>
                {status.text}
              </button>
            </li>
          ))}
        </div>
      </div>
    )      
  }

The nextStep function changes a users status to whatever the value of the pressed button is (all based on the data) I don't want a user to be able to press a button multiple times however. How can I disable the button that was pressed without disabling every button in the list?

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

0

Just add isDisabled flag in your state data array. Like below code

[{key: 1, text: 'aa', isDisabled: true}, {key: 1, text: 'ab', isDisabled: false}]

update this isDisabled flag on Button onClick event, Based on this isDisabled flag you can disable button click.

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