Answer the question
In order to leave comments, you need to log in
How to animate a list in React?
Hello. Can you please tell me how to animate a dynamic list in React using functional components?
Previously, with classes, it was possible to set and remove animations in life cycles.
Here is an example
Answer the question
In order to leave comments, you need to log in
Install the package
Import
Animate
<TransitionGroup className="items-section__list">
{list.map(elem => (
<CSSTransition key={elem} timeout={500} classNames="move">
<h5 key={elem}>{elem}</h5>
</CSSTransition>
))}
</TransitionGroup>
.move-enter {
opacity: 0.01;
transform: translate(-40px, 0);
}
.move-enter-active {
opacity: 1;
transform: translate(0, 0);
transition: all 500ms ease-in;
}
.move-exit {
opacity: 1;
transform: translate(0, 0);
}
.move-exit-active {
opacity: 0.01;
transform: translate(40px, 0);
transition: all 500ms ease-in;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question