Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!