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

179
Views
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 answers
Answer question

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 Report

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