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

370
Vistas
(React.js) How to disable inputs until the previous input is enterred?

I have an input element returned by an Array of strings like the image below. How can I write the input component so that the subsequent inputs are disabled until the current input is entered by the user? Users can only start with the input from the top left then move to the right accordingly.

function() {

return (
<div>

  {strArr.map((item, index) => (
    <input />
  ))}
</div>
)}

Thanks for your help!

enter image description here

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

0

  • First of all set state and call it like isActive
  • Second, give your input an identifier like id that can be equal to the current
  • So, by default, your state will be initialized with 0;
  • Set disabled property of your input dynamically, if isActive is not equal to the current state it gonna be disabled,
function() {
const [isActive, setIsActive] = React.useState(0);
const handleOnInputChange = (index)=>{
setIsActive(index+1)
}
return (
<div>

  {strArr.map((item, index) => (
    <input ket={index} id={index} disabled={isActive !== index} onChange={()=>handleOnInputChange(index)}/>
  ))}
</div>
)}
  • This gonna work if you have only to write a single character in your input
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