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

185
Vistas
icon disappears when cursor is hovered over icon

What I am trying to do is; Opening a tooltip when hovering over the icon. I managed to do this, but I don't want the icon to disappear when the cursor hovers over the icon.

const [hover, setHover] = useState(false);
const onHover = () => {
  setHover(true);
};

const onLeave = () => {
  setHover(false);
};
<div onMouseEnter={onHover} onMouseLeave={onLeave}>
  {hover ? <InstallmentInformation installmentList={props.location.state.toBePaidList}/> : <AS.InfoIcon />} //AS.InfoIcon--> My icon
</div>

What can I do so that the icon does not disappear?

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

0

Just move the icon outside the conditional

<div onMouseEnter={onHover} onMouseLeave={onLeave}>
  <AS.InfoIcon />
  {hover && <InstallmentInformation installmentList={props.location.state.toBePaidList}/> } 
</div>

I'm expecting hover to always be a boolean, if it's not make it a boolean by using !!hover to avoid unexpected behavior.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I don't know what kind of effect/positioning you want for your tooltip but since you icon should not disappear , it should not be conditioned. Try to start with something like that :

     <div 
       onMouseEnter={onHover} 
       onMouseLeave={onLeave}>
     {hover && <InstallmentInformation
                installmentList={props.location.state.toBePaidList}/>}
     <AS.InfoIcon />

Plus, the style of your tooltip should contain a position property sets to 'absolute' and then place it where you want.

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