Reputation: 4391
My desired affect:
This sounds simple but I'm struggling to make it happen. So far I have a number of routes setup using react-router
v4 and I am using CSSTransitionGroup
to add movement to routes and components.
The problem I am having is:
Any hints or resources on how to achieve this desired affect would be great!
TL;DR: transitionLeaveTimeout is not being applied to animated components inside an animated route.
Upvotes: 2
Views: 816
Reputation: 4391
I've found a solution, but it's not particularly elegant.
In brief, the problem occurred because any components which are rendered by a route technically only ever appear. So what I had to do was use the route's render
function, like so:
<CSSTransitionGroup
transitionName="test"
transitionAppear={true}
transitionAppearTimeout={1000}
transitionEnterTimeout={1000}
transitionLeaveTimeout={1000}>
<Route exact path="/about" location={this.props.location} key={this.props.location.key} render={({ location }) => (
<CSSTransitionGroup
transitionName="test2"
transitionAppear={true}
transitionAppearTimeout={2000}
transitionEnterTimeout={1000}
transitionLeaveTimeout={1000}>
<AboutBox key={this.props.location.key} />
</CSSTransitionGroup>
)} />
</CSSTransitionGroup>
So what is happening here is:
component=
, it is using a render function (render=
) to call the component (AboutBox)If I were to move that transition group to the component itself, only appear would be available to it.
Hope this helps somebody!
Upvotes: 1