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

150
Visualizações
I have multiple inputs and i wanted to AutoFocus the next input after the first input is accepted

I have this in my Row.jsx

  const Row = ({ move }) => {
  const focusRef = useRef(null)
  const check = e => {setValue(e.target.value)}
  return(
    <input type='text' ref={focusRef} key={move} id={move} readOnly={!(move === tries)} autoFocus={move === tries} value= 
      {value} onChange={check} />
  )}

My app.jsx

import { createContext, useState } from 'react';
import Row from './components/Row';
export const TriesContext = createContext()

function App() {
  const [tries, setTries] = useState(0)
  return (
    <div className='space-y-2'>
      <TriesContext.Provider value={{ tries, setTries }}>
        <Row move={0} />
        <Row move={1} />
        <Row move={2} />
        <Row move={3} />
        <Row move={4} />
        <Row move={5} />
      </TriesContext.Provider>
    </div>
  );
}

Actually I want the next components to be autoFocused after the first input is accepted. I have added the autoFocus={move === tries} but that doesnt work apparently.

note that the inputs have to filled in ascending order(i have made the inputs readonly)and that is working. Can I get some help?

about 4 years ago · Juan Pablo Isaza
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