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

173
Vistas
React: programmatically focus library components?

I have a third-party radio button that loses tab focus when we interact with it via the keyboard; i.e. tabbing to it and then pressing enter causes the focus to move on to another element, when I want the focus to stay on the radio button. Is there a way to programmatically focus the radio button from inside its onChange handler? My code looks something like this, which doesn't work:

const Component = (event) =>{
   const handleChange = ()=>{
      //business logic
      event.target.focus()
   }
   return(<RadioBtn onChange={handleChange}/>)
}

I also tried using a ref but that didn't work either, did I do something wrong?

const Component = (event) =>{
   const rdbRef = useRef();

   const handleChange = ()=>{
      //business logic
      rdbRef.current.focus();
   }
   return(<RadioBtn 
           onChange={handleChange}
           ref={rdbRef}/>)
}
about 4 years ago · Juan Pablo Isaza
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