我有一個簡單的例子,反應路由器v4 &路由轉換。它遵循https://reacttraining.com/react-router/web/example/animated-transitions所示的示例。但是,結果只顯示最後一條路線。其他人只是空白。 https://codesandbox.io/s/r0PvB30wk。反應路由器v4&CSS轉換組
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import { CSSTransitionGroup } from 'react-transition-group'
import About from './components/About';
import Home from './components/Home';
import Topics from './components/Topics';
import './styles.css'
const BasicExample =() => (
<Router>
<Route render={({ location }) => (
<div>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/topics">Topics</Link></li>
</ul>
<hr />
<CSSTransitionGroup
transitionEnterTimeout={300}
transitionLeaveTimeout={300}
transitionName="fade"
>
<Route exact path="/" component={Home} location={location} key={location.key} />
<Route path="/about" component={About} location={location} key={location.key} />
<Route path="/topics" component={Topics} location={location} key={location.key} />
</CSSTransitionGroup>
</div>
)}/>
</Router>
);
render(<BasicExample />, document.body);