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

371
Visualizações
(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 Respostas
Responde à pergunta

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 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