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

185
Views
reactjs set visible on hover

I have a card that has a button inside it. The button is set visible only when the user hovers the card. The problem is when the user hovers the card, the button is displayed, then if hovering over the button, the button dissapears because the onMouseOut of card reacts and sets the boolean to false.


const Display = (props) => {
    const [isHoveringCard, setIsHoveringCard] = useState(false);
    const [isHoveringButton, setIsHoveringButton] = useState(false);
    const handleMouseOverCard = () => {
        setIsHoveringCard(true);
    };
    const handleMouseOutCard = () => {
        if (!isHoveringButton) {
            setIsHoveringCard(false);
        }
    };
    const handleMouseOverButton = () => {
        setIsHoveringButton(true);
    };
    const handleMouseOutButton = () => {
        setIsHoveringButton(false);
    };
    return (
        <CCard
            style={{ width: '18rem', margin: '20px' }}
            onMouseOver={handleMouseOverCard}
            onMouseOut={handleMouseOutCard}

        >
            <CCardImage
                orientation="top"
                src={props.previewimgname}
                style={{ height: '12rem' }}

            />
            {isHoveringCard &&
                <CButton
                    onMouseOver={handleMouseOverButton}
                    onMouseOut={handleMouseOutButton}
                    className='display-card-button'
                    onClick={() => {
                        props.selectDisplay()
                    }}>
                    Learn More
                </CButton>}
            <CCardBody style={{ height: '10rem' }}>
                <CCardText>
                    <CIcon icon={cilLocationPin} className="me-2" />
                    {props.address}, {props.city}, {props.zipcode}
                </CCardText>
                <CCardTitle>{props.name}</CCardTitle>
                <CCardText>
                    {props.description}
                </CCardText>
            </CCardBody>
        </CCard>
    )
}
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!