简体   繁体   English

react-transition-group不与React Router一起使用

[英]react-transition-group not working with React Router

I have a problem with React transitions group. 我有React过渡组的问题。 For some reason, the fade in and out is not working on Router Switch. 出于某种原因,淡入和淡出不适用于路由器交换机。 I have read the documentation and implemented it inside my App. 我已经阅读了文档并在我的应用程序中实现了它。

Don't know what is wrong with my code. 不知道我的代码有什么问题。

My React code: 我的反应代码:

const App = () => (
    <Router>
        <Menu />
        <TransitionGroup>
            <CSSTransition
                timeout={{ enter: 300, exit: 300 }}
                classNames={'fade'}>
                <Switch>
                    {routes.map(route => (
                        <Route
                            exact
                            key={route.path}
                            path={route.path}
                            component={route.component}
                        />
                    ))}
                </Switch>
            </CSSTransition>
        </TransitionGroup>
    </Router>
);

export default App;

Css code: Css代码:

.fade-enter {
    opacity: 0.01;
    &.fade-enter-active {
        opacity: 1;
        transition: opacity 300ms ease-in;
    }
}

.fade-exit {
    opacity: 1;
    &-active {
        opacity: 0.01;
        transition: opacity 300ms ease-in;
    }
}

Nevermind, forgot to wrap it: 没关系,忘了把它包起来:

<Route render={({ location }) => (

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 模态上的反应过渡组 - react-transition-group on Modal 使用 2017 react-router react-transition-group 示例,其中内容组件不呈现 - Working from a 2017 react-router react-transition-group example where content components don't render 使用 React 和 react-transition-group 卸载动画 - Animation on unmount with React and react-transition-group react-transition-group中的退出延迟动画 - Exit delay animation in react-transition-group 使用 react-transition-group 可以吗? - Is it ok to use react-transition-group? 无法安装反应过渡组 - Can't install react-transition-group 尝试将 react-transition-group 实现到 react-router 中会产生错误:“元素类型无效......” - Trying to implement react-transition-group into react-router generates error : 'Element type is invalid ...' 使用react-transition-group在转换之前元素值移位和更改 - Element values shifting and changing before transition with react-transition-group 反应“反应过渡组”不起作用 - React “react-transition-group” doesn't work react-transition-group v2 和 react-router-dom v4。 为什么动画会同时更改内部和外部组件中的数据? - react-transition-group v2 and react-router-dom v4. Why animation change the data in both: inner and outer components?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM