簡體   English   中英

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

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

我有React過渡組的問題。 出於某種原因,淡入和淡出不適用於路由器交換機。 我已經閱讀了文檔並在我的應用程序中實現了它。

不知道我的代碼有什么問題。

我的反應代碼:

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代碼:

.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;
    }
}

沒關系,忘了把它包起來:

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

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM