我正在使用反应过渡来淡入和淡出内容。
大多数情况下都可以正常工作,但是我注意到一页在不经过过渡状态的情况下即刻呈现。
我的活动:
routeChange =(e) => {
if(e.target.nodeName == "LI" || e.target.nodeName == "a") {
return;
}
let path = "/detail/" + this.state.merchant.id;
this.props.dispatch(push(path));
}
该文件中的我的mapDispatchToProps
function mapDispatchToProps(dispatch) {
let actions = bindActionCreators({ saveColor }, dispatch);
return { ...actions, dispatch };
}
这是我的路径的工作方式:
<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>
);
}}
/>
还有我的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;
}
反正有没有在this.props.dispatch(push(path))上强制动画?