The title maybe not on spot, but I will try to explain here. I've been using SwitchTransition in in-out
mode but since my animation was done using mostly hook useSpring from react-spring
package, I would rather move from React Transition Group
completely. But I am not quite sure how to achieve the same effect. When a transition happens (for routes) I need for the old component stay visible (say for 2000 milliseconds) while the new one is already visible. Looking at the hook useTransition
in react-spring
I don't see a way to introduce a delay for leave
.
const transition = useTransition(show, null, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
config: {
duration: 200, // duration for the whole animation form start to end
},
})
In SwitchTransition
it would be something like that:
<SwitchTransition mode='in-out'>
<CSSTransition
key={location.pathname}
timeout={{ enter: 2000, exit: 400 }}
unmountOnExit
onEnter={()=>{callback}}
>
/* here go routes */
</CSSTransition>
</SwitchTransition>
How to do the same in React Spring with useTransition
?