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

126
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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