I am using a react transition to fade in and fade out content.
Mostly this is working fine, however I am noticing that one page is rendering instantly, without going through the transition state.
My event:
routeChange =(e) => {
if(e.target.nodeName == "LI" || e.target.nodeName == "a") {
return;
}
let path = "/detail/" + this.state.merchant.id;
this.props.dispatch(push(path));
}
And my mapDispatchToProps in that file
function mapDispatchToProps(dispatch) {
let actions = bindActionCreators({ saveColor }, dispatch);
return { ...actions, dispatch };
}
Here is how my pathing works:
<Route
render={({ location }) => {
const { pathname } = location;
return (
<TransitionGroup className="transition-group">
<CSSTransition
key={pathname}
classNames="page"
timeout={{
enter: 1000,
exit: 1000,
}}
>
<Route
location={location}
render={() => (
<Switch>
<Route exact path="/login" component={LoginPage} />
<Route exact path="/detail" component={Detail} />
<PrivateRoute exact path="/" component={Cards} />
</Switch>
)}
/>
</CSSTransition>
</TransitionGroup>
);
}}
/>
And my CSS:
.page-enter {
opacity: 0.01;
}
.page-enter.page-enter-active {
opacity: 1;
transition: opacity 3000ms ease-in;
}
.page-exit {
opacity: 0;
}
.page-exit.page-exit-active {
opacity: 0.01;
transition: opacity 3000ms ease-in;
}
Is there anyway to force the animation on this.props.dispatch(push(path)) ?
.page-exit.page-exit-active
have the transition attributeease-out
instead ofease-in
? – Gwenngwennethhistory
andmatch
seem to be missing. Usually how I handle this is by doing{...props}
, but since you're doing deconstructing in the first route, you can't. I would try without deconstruction in your first route so you can pass the required props. – Gwenngwenneth