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

138
Vistas
clicking a button second time, getting different result

When a button (material ui) is clicked for a second time, I want that button to be disabled (disabled={true}). I did not find any example related to this on StackOverflow.

<Button
  onClick={this.startDraw.bind(this)}
  disabled={}
  startIcon={<Brush />}
>

At first, the button is clickable. When it is clicked, something happens, but when this same button is clicked a second time, the button should be disabled (cannot be clicked anymore).

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For Class component use

    state = {
    count: 0
    };
this.setState({ count: count + 1 }); // use this on your button click

and for the button part

   <Button
    onClick={this.startDraw.bind(this)}
    disabled={count == 2}
    startIcon={<Brush />}
  />

for functional component use this approach


   const [count , setCount ] = useState(0);
   setCount(count + 1) // use this on your button call

    <Button
    onClick={this.startDraw.bind(this)}
    disabled={count == 2}
    startIcon={<Brush />}
/>

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