Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!