I am trying to implement an animation on a react component that triggers every time it re-renders due to prop changes:
react:
function Card({ cardText }) {
return <div className="roll-out">{cardText}<div/>
}
Here's the CSS I used:
@keyframes rollout {
0% { transform: translateY(-100px); }
100% { transform: none; }
}
.roll-out {
animation: rollout 0.4s;
}
However, I'm facing an issue where the animation only plays once, during the initial render. I want it to play every time <Card />
re-renders due to changes in cardText
. How can this be achieved?