File tree 3 files changed +13
-10
lines changed
3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- import { BrowserRouter as Router , Route } from 'react-router-dom'
2
+ import { Switch , Route , withRouter } from 'react-router-dom'
3
3
import LoginContainer from 'components/Login/LoginContainer'
4
4
import ProtectedContainer from 'components/Protected/ProtectedContainer'
5
5
import HomeContainer from 'components/Home/HomeContainer'
6
- import Header from 'components/Header'
7
6
import 'App.css'
8
7
9
8
const App = ( ) => (
10
- < Router >
11
- < div >
12
- < Header />
9
+ < Switch >
13
10
< Route exact path = "/" component = { HomeContainer } />
14
11
< Route path = "/login" component = { LoginContainer } />
15
12
< Route path = "/protected" component = { ProtectedContainer } />
16
- </ div >
17
- </ Router >
13
+ </ Switch >
18
14
)
19
15
20
- export default App
16
+ export default withRouter ( App )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class LoginContainer extends React.Component {
16
16
return (
17
17
< div >
18
18
{ loggedIn ? (
19
- < Redirect to = "/home " />
19
+ < Redirect to = "/" />
20
20
) : (
21
21
< LoginForm
22
22
handleSubmit = { handleSubmit }
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import { Provider } from 'react-redux'
6
6
import { homeReducer } from './reducers'
7
7
import { createStore , applyMiddleware } from 'redux'
8
8
import thunk from 'redux-thunk'
9
+ import { BrowserRouter as Router } from 'react-router-dom'
10
+ import Header from 'components/Header'
9
11
10
12
const store = createStore (
11
13
homeReducer ,
@@ -15,7 +17,12 @@ const store = createStore(
15
17
16
18
ReactDOM . render (
17
19
< Provider store = { store } >
18
- < App />
20
+ < Router >
21
+ < div >
22
+ < Header />
23
+ < App />
24
+ </ div >
25
+ </ Router >
19
26
</ Provider > ,
20
27
document . getElementById ( 'root' )
21
28
)
You can’t perform that action at this time.
0 commit comments