File tree Expand file tree Collapse file tree 7 files changed +46
-8
lines changed Expand file tree Collapse file tree 7 files changed +46
-8
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
+ < head >
3
4
< meta charset =utf-8/ >
5
+ < link rel ="stylesheet " href ="index.css ">
4
6
< title > My First React Router App</ title >
7
+ </ head >
5
8
< div id =app > </ div >
6
9
< script src ="bundle.js "> </ script >
Original file line number Diff line number Diff line change @@ -3,15 +3,19 @@ import { render } from 'react-dom'
3
3
import { Router , Route , hashHistory } from 'react-router'
4
4
import About from './modules/About'
5
5
import Repos from './modules/Repos'
6
+ import Repo from './modules/Repo'
6
7
import App from './modules/App'
7
8
8
9
9
10
render (
10
11
(
11
12
< Router history = { hashHistory } >
12
- < Route path = "/" component = { App } />
13
- < Route path = "about" component = { About } />
14
- < Route path = "repos" component = { Repos } />
13
+ < Route path = "/" component = { App } >
14
+ < Route path = "/repos" component = { Repos } >
15
+ < Route path = "/repos/:userName/:repoName" component = { Repo } />
16
+ </ Route >
17
+ < Route path = "/about" component = { About } />
18
+ </ Route >
15
19
</ Router >
16
20
) , document . getElementById ( 'app' )
17
21
)
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { Link } from 'react-router'
3
+ import NavLink from './NavLink'
3
4
4
5
export default React . createClass ( {
5
6
render ( ) {
6
7
return (
7
8
< div >
8
9
< h1 > React Router Tutorial</ h1 >
9
10
< ul role = "nav" >
10
- < li > < Link to = "/about" > About</ Link > </ li >
11
- < li > < Link to = "/repos" > Repos</ Link > </ li >
11
+ < li > < NavLink to = "/about" > About</ NavLink > </ li >
12
+ < li > < NavLink to = "/repos" > Repos</ NavLink > </ li >
12
13
</ ul >
14
+ { this . props . children }
13
15
</ div >
14
16
)
15
17
}
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { Link } from 'react-router'
3
+
4
+ export default React . createClass ( {
5
+ render ( ) {
6
+ return < Link { ...this . props } activeClassName = "active" />
7
+ }
8
+ } )
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+
3
+ export default React . createClass ( {
4
+ render ( ) {
5
+ return (
6
+ < div >
7
+ < h2 > { this . props . params . repoName } </ h2 >
8
+ </ div >
9
+ )
10
+ }
11
+ } )
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
+ import { Link } from 'react-router'
3
+ import NavLink from './NavLink'
2
4
3
5
export default React . createClass ( {
4
-
5
6
render ( ) {
6
- return
7
+ return (
7
8
< div >
8
- Repos
9
+ < h2 > Repos</ h2 >
10
+ < ul >
11
+ < li > < NavLink to = "/repos/reactjs/react-router" > React Router</ NavLink > </ li >
12
+ < li > < NavLink to = "/repos/facebook/react" > React</ NavLink > </ li >
13
+ </ ul >
14
+ { this . props . children }
9
15
</ div >
16
+ )
10
17
}
11
18
} )
You can’t perform that action at this time.
0 commit comments