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

81
Visualizações
Animation with styled-components in react

I want to run the animation in the last ten seconds of a timer.First, I tried with keyframes and it was how I wanted but this time if I do not refresh the page animation did not work. I commented it and tried another way which is below:

useEffect(() => {
if (time <= 30 && disabled === false && time !== 0) {
  setTimeout(() => setTime(time - 1), 1000);
} else if (disabled) {
  setTime(30);
  setAnimated(null);
} else if (time === 0) {
  setDisabled(!disabled);
  setInputValue("Time is over");
}
if (time <= 10 && animated !== null && disabled === false && time !== 0) {
  setAnimated("animation 1s infinite");
}
}, [time, disabled]);

Countdown component:

const CountDown = () => {
const { time, animated } = useContext(WordContext);
return (
<Time>
  <Counting style={{ animation: animated !== null ? animated : "" }}>
    00:00:{time}
  </Counting>
</Time>
  );
};

Css:

export const Counting = styled.p`
margin: auto;
font-size: 40px;
line-height: 1;
animation: ${animation};
// animation-fill-mode: backwards;
// animation-delay: 23s;
// animation-iteration-count: 10;
`;

Do you have any suggestions or corrections?. Thanks in advance.

about 4 years ago · Santiago Trujillo
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