File tree Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Original file line number Diff line number Diff line change
1
+ .active {
2
+ color : green;
3
+ }
Original file line number Diff line number Diff line change 1
1
<!doctype html public "storage">
2
2
< html >
3
3
< meta charset =utf-8/ >
4
+ < link rel ="stylesheet " href ="index.css " />
4
5
< title > My First React Router App</ title >
5
6
< div id =app > </ div >
6
7
< script src ="bundle.js "> </ script >
Original file line number Diff line number Diff line change @@ -8,8 +8,9 @@ import Repos from './modules/Repos';
8
8
9
9
render ( (
10
10
< 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 >
14
15
</ Router >
15
16
) , document . getElementById ( 'app' ) )
Original file line number Diff line number Diff line change 8
8
9
9
import React , { Component } from 'react' ;
10
10
import { Link } from 'react-router' ;
11
+ import NavLink from './NavLink' ;
11
12
12
13
class App extends Component {
13
14
render ( ) {
14
15
return (
15
16
< div >
16
17
< h1 > React Router Tutorial</ h1 >
17
18
< 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 >
20
21
</ ul >
22
+
23
+ { /* add this */ }
24
+ { this . props . children }
21
25
</ div >
22
26
)
23
27
}
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments