4

I'm trying to animate a component entering and leaving the dom, but I also want to animate it being replaced with another instance of itself. I tried everything on react-transition-group and nothing works as I expect. There is Transition group, which is able to handle elements leaving the dom and getting fully empty, but it is not capable of waiting for one element to leave before animating the next. I also tried SwitchTransition, but that one is not able to accept empty children, you need to always provide at least one child, which will be animated, so I can not just put a random empty div there.

I suspect that I can achieve this playing with complete callbacks, but I am unsure about how.

Danielo515
  • 5,996
  • 4
  • 32
  • 66
  • Did you ever solve this? I’m used to Vue transitions, just getting to grips with React transitions and need to use SwitchTransition for exactly what you’re describing. – Simon Rogers Jan 05 '23 at 18:32
  • 1
    Just wanted to say I’ve opened an issue here outlining a possible solution that _nearly_ works – unfortunately it gets a bit patchy once entering/leaving the same element repeatedly for the null/empty value and I haven’t figured out why yet. https://github.com/reactjs/react-transition-group/issues/877 – Simon Rogers Jan 06 '23 at 11:19

0 Answers0