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

168
Views
React/animation - render animation everytime on button click when state or props change

I am trying to have the animation work everytime i click on the buttons in the below project

Code - https://codesandbox.io/s/8fjs8i

Description There are 3 buttons named first, second and third. when i click on first, the purple box below shows first, when i click on second it shows second and so on, basically the div is updating everytime based on button click.

Problem : but the animation fadIn that i have given to the div works only on application load. how can i make it work everytime i click the button so the the box fadesIN with animation for every click.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

const Renders = ({ arr }) => {
  const [load, setLoad] = useState(false);

  useEffect(() => {
    setLoad(true);
    setTimeout(() => {
    setLoad(false);
    }, 1);

  }, [arr]);

  if (load) return <></>;

  return (
    <div className="renders">
      <div className="zoomers">{arr}</div>
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza Report

0

This another way you can do it:

const Renders = ({ arr }) => {
  const [load, setLoad] = useState(false);

  useEffect(() => {
    setLoad(true);
    setTimeout(() => {
    setLoad(false);
    }, 1);

  }, [arr]);

  return (
    <div className="renders">
      <div className={load ? '' : "zoomers"}>{arr}</div>
    </div>
  );
};

Now look the different, before you load and unload, now its just a play with the class name, the idea that every time you load element with the animation class so its start to work

about 4 years ago · Juan Pablo Isaza Report
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!