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

193
Visualizações
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 à 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