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

194
Vistas
Is it best to animate a React component to be visible with opacity (already rendering it) or css-animation (only rendering when needed)?

Often, a React component will need to be animated when its suppose to come into view. Think about a modal or popup or mobile filter or search that appears when a Button is clicked.

Say we want to fade the filter/modal/screen into view. We have two options

Render the component but hide it with opacity until opened:

<MyComponent style={{opacity: isOpen ? '1' : '0'}}/>
  • Pros: we can fade in and fade out, because the component is always there. just change opacity and add css transition.

  • Cons: the react component is rendered. This can't be good for performance right? right?


Render the component only when opened but use css animations

{isOpen && <MyComponent />}

css for above component

  animation-duration: 300ms;
  animation-name: fadeIn;

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }


  • Pros: this has to be better for performance, right? right?
  • Cons: fading out is hard. It requires delay from removing it from the DOM. since you can't transition a fade when removing component from the DOM.
about 4 years ago · Juan Pablo Isaza
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