The CSSTransitionGroup
in the React Addons works fine for simple things, but since React components don’t have much knowledge of their children, more complex nested components can be re-rendering while the transitions are happening. This can lead to jerky animation.
This example implements a custom AnimationItem
component that sits inside the TransitionGroup
— note the lack of the CSS
prefix there — which has an API for handling the various transition events. I’ve reimplemented the behaviour from the CSSTransitionsGroup
in the AnimationItem
component but using requestAnimationFrame
to wait a render tick before triggering the transition, and Arrival to determine when the transition ends.
Again, it’s unnecessary in this example because the components are so simple, but it makes a massive difference on more complex components.
Forked from Max's Pen [Cus