Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda