Redirect
import {
Route, NavLink, Switch, Redirect} from 'react-router-dom';
任何以’/‘为前缀的url,都会重定位到’/posts/
<Redirect from='/' to='/posts'/>
Conditional Redirect
将< Redirect /> 放入return中,即会跳转页面;
所以需要用let变量存放< Redirct /> , 设置在特定时候显示——跳转;
let redirect = null;
if(this.state.submitted){
redirect=<Redirect to="/posts" />;
}