Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

321
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda