Skip to content

Commit 39d38cd

Browse files
committed
lessons 05 finish
1 parent cdced43 commit 39d38cd

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

lessons/01-setting-up/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.active {
2+
color: green;
3+
}

lessons/01-setting-up/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!doctype html public "storage">
22
<html>
33
<meta charset=utf-8/>
4+
<link rel="stylesheet" href="index.css" />
45
<title>My First React Router App</title>
56
<div id=app></div>
67
<script src="bundle.js"></script>

lessons/01-setting-up/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import Repos from './modules/Repos';
88

99
render((
1010
<Router history={hashHistory}>
11-
<Route path="/" component={App}/>
12-
<Route path="/repos" component={Repos}/>
13-
<Route path="/about" component={About}/>
11+
<Route path="/" component={App}>
12+
<Route path="/repos" component={Repos}/>
13+
<Route path="/about" component={About}/>
14+
</Route>
1415
</Router>
1516
), document.getElementById('app'))

lessons/01-setting-up/modules/App.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88

99
import React, { Component } from 'react';
1010
import { Link } from 'react-router';
11+
import NavLink from './NavLink';
1112

1213
class App extends Component {
1314
render(){
1415
return (
1516
<div>
1617
<h1>React Router Tutorial</h1>
1718
<ul role='nav'>
18-
<li><Link to='/about'>About</Link></li>
19-
<li><Link to='/repos'>Repos</Link></li>
19+
<li><NavLink to='/about'>About</NavLink></li>
20+
<li><NavLink to='/repos'>Repos</NavLink></li>
2021
</ul>
22+
23+
{/* add this */}
24+
{this.props.children}
2125
</div>
2226
)
2327
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React, { Component } from 'react';
2+
import { Link } from 'react-router';
3+
4+
class NavLink extends Component {
5+
render(){
6+
return <Link {...this.props} activeClassName="active"/>
7+
}
8+
}
9+
10+
export default NavLink;

0 commit comments

Comments
 (0)