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

129
Visualizações
CSSTransition not working despite modal gets mounted and unmounted

It is working as my modalOverlay gets mounted and unmounted based on the state props.show it recieves from parent. but the transitions are not happening. I want modalOverlay to have opacity of 0 to 0.9 and some transition as well. I checked on inspect element the classes like my-node-enter my-node-enter-active and others do get added. then why am I not getting the opacity reduced and transitions. Please Help

const ModalOverlay=(props)=>{

    const clickHandler=()=>{
        props.closeModal();
    }
    


    return(
        <>
            <CSSTransition
            mountOnEnter
            unmountOnExit
            in={props.show}
            timeout={200}
            classNames="my-node">
            <div className={classes.modalOverlay}>
                <div className={classes.closeModal}>
                    <div className={classes.closeButton} onClick={clickHandler}>
                                    
                    </div>
                </div>
                <div className={classes.options}></div>
                <div className={classes.contactUs}></div> 
            </div>
            </CSSTransition>
            
        </>
    )
}

export default ModalOverlay

Here's the css

.modalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    overflow: auto;
    background: rgb(0, 0, 0); /* Just to visualize the extent */
    /* opacity: 0.9; */
    height: 100vh;
    display: flex;
    flex-direction: column;
    
    
  }

  .closeModal{
      
      background-color: aqua;
      width: 100%;
      height: 10%;
  }
  .options{
    background-color: bisque;
    width: 100%;
    height: 60%;
}
.contactUs{
   background-color: rgb(255, 66, 66);
    width: 100%;
    height: 30%;
}

.closeButton{
    margin-right: 15px;
    
}

  .fade-in-enter{
    opacity: 0;
  }
  .fade-in-enter-active{
    opacity: 1;
    transition: opacity 200ms;
  }
  .fade-in-exit{
    opacity: 1;
  }
  .fade-in-exit-active{
    opacity: 0;
    transition: opacity 200ms;
  }

  .my-node-enter {
    opacity: 0;
  }
  .my-node-enter-active {
    opacity: 1;
    transition: opacity 200ms;
  }
  .my-node-exit {
    opacity: 1;
  }
  .my-node-exit-active {
    opacity: 0;
    transition: opacity 200ms;
  }

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

For the fade in, I think that the problem might be that the transition property is set at the same time as opacity 1. Try adding the transition property on .modalOverlay instead.

I do not know what library you are using for this modal, but a common problem trying to get a component to fade out when it unmounts is that it unmounts immediately, not leaving any time to see the transition occur.

about 4 years ago · Juan Pablo Isaza Relatório

0

The syntax to add classes from module css files is different.

A proper solution to my problem is mentioned here: (React) CSSTransition with css modules

about 4 years ago · Juan Pablo Isaza Relatório
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