Skip to content

Commit e83fbd1

Browse files
Navegação com React-router (Versão 2)
1 parent b6c97fa commit e83fbd1

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

my-money-app/frontend/src/common/template/menu.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import MenuTree from './menuTree'
44

55
export default props => (
66
<ul className='sidebar-menu'>
7-
<MenuItem path='#' label='Dashboard' icon='dashboard' />
7+
<MenuItem path='/' label='Dashboard' icon='dashboard' />
88
<MenuTree label='Cadastro' icon='edit'>
9-
<MenuItem path='#billingCycles'
9+
<MenuItem path='billingCycles'
1010
label='Ciclos de Pagamentos' icon='usd' />
1111
</MenuTree>
1212
</ul>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react'
2+
import { Link } from 'react-router'
23

34
export default props => (
45
<li>
5-
<a href={props.path}>
6+
<Link to={props.path}>
67
<i className={`fa fa-${props.icon}`}></i> <span>{props.label}</span>
7-
</a>
8+
</Link>
89
</li>
910
)

my-money-app/frontend/src/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import promise from 'redux-promise'
77
import multi from 'redux-multi'
88
import thunk from 'redux-thunk'
99

10-
import App from './main/app'
10+
import Routes from './main/routes'
1111
import reducers from './main/reducers'
1212

1313
const devTools = window.__REDUX_DEVTOOLS_EXTENSION__
1414
&& window.__REDUX_DEVTOOLS_EXTENSION__()
1515
const store = applyMiddleware(multi, thunk, promise)(createStore)(reducers, devTools)
1616
ReactDOM.render(
1717
<Provider store={store}>
18-
<App />
18+
<Routes />
1919
</Provider>
2020
, document.getElementById('app'))

my-money-app/frontend/src/main/app.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import React from 'react'
44
import Header from '../common/template/header'
55
import SideBar from '../common/template/sideBar'
66
import Footer from '../common/template/footer'
7-
import Routes from './routes'
87
import Messages from '../common/msg/messages'
98

109
export default props => (
1110
<div className='wrapper'>
1211
<Header />
1312
<SideBar />
1413
<div className='content-wrapper'>
15-
<Routes />
14+
{props.children}
1615
</div>
1716
<Footer />
1817
<Messages />
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import React from 'react'
2-
import { Router, Route, Redirect, hashHistory } from 'react-router'
2+
import { Router, Route, IndexRoute, Redirect, hashHistory } from 'react-router'
33

4+
import App from './app'
45
import Dashboard from '../dashboard/dashboard'
56
import BillingCycle from '../billingCycle/billingCycle'
67

78
export default props => (
89
<Router history={hashHistory}>
9-
<Route path='/' component={Dashboard} />
10-
<Route path='/billingCycles' component={BillingCycle} />
10+
<Route path='/' component={App}>
11+
<IndexRoute component={Dashboard} />
12+
<Route path='billingCycles' component={BillingCycle} />
13+
</Route>
1114
<Redirect from='*' to='/' />
1215
</Router>
1316
)

0 commit comments

Comments
 (0)