1import { Route, Redirect } from 'react-router'
2
3<Route exact path="/" render={() => (
4 loggedIn ? (
5 <Redirect to="/dashboard"/>
6 ) : (
7 <PublicHomePage/>
8 )
9)}/>
1<Route exact path="/">
2 {loggedIn ? <Redirect to="/profile" /> : <HomePage />}
3</Route>
1<Route exact path="/">
2 {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
3</Route>
1<Route exact path="/">
2 {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
3</Route>
4
1state = { redirect: null };
2render() {
3 if (this.state.redirect) {
4 return <Redirect to={this.state.redirect} />
5 }
6 return(
7 // Your Code goes here
8 )
9}
10