Skip to content

Commit bbadaa6

Browse files
learned about URL Params- thank god
1 parent 718ffec commit bbadaa6

File tree

9 files changed

+105
-2
lines changed

9 files changed

+105
-2
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
@@ -2,5 +2,6 @@
22
<html>
33
<meta charset=utf-8/>
44
<title>My First React Router App</title>
5+
<link rel="stylesheet" href="index.css" />
56
<div id=app></div>
67
<script src="bundle.js"></script>

lessons/01-setting-up/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1+
import { Router, Route, hashHistory} from 'react-router'
12
import React from 'react'
23
import { render } from 'react-dom'
34
import App from './modules/App'
4-
render(<App/>, document.getElementById('app'))
5+
import About from './modules/About'
6+
import Repos from './modules/Repos'
7+
import Repo from './modules/Repo'
8+
import Sig from './modules/Sig'
9+
10+
render((
11+
<Router history={hashHistory}>
12+
<Route path="/" component={App}>
13+
<Route path="/repos" component={Repos}/>
14+
{/* add the new route */}
15+
<Route path="/repos/:userName/:repoName" component={Repo}/>
16+
<Route path="/about" component={About}/>
17+
<Route path="/about/:user/:sig" component={Sig}/>
18+
</Route>
19+
</Router>
20+
), document.getElementById('app'))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react'
2+
import { Link } from 'react-router'
3+
4+
export default React.createClass({
5+
render() {
6+
return (
7+
<div>
8+
<h2>About</h2>
9+
10+
<ul>
11+
<li><Link to="/about/holla/force">Holla</Link></li>
12+
<li><Link to="/about/atcha/power">Atcha</Link></li>
13+
</ul>
14+
</div>
15+
)
16+
}
17+
})
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import React from 'react'
2+
import { Link } from 'react-router'
3+
import NavLink from './NavLink'
24

35
export default React.createClass({
46
render() {
5-
return <div>Hello, React Router!</div>
7+
return (
8+
<div>
9+
<h1>Ghettohub Issues</h1>
10+
<ul role="nav">
11+
<li><NavLink to="/about">About</NavLink></li>
12+
<li><NavLink to="/repos">Repos</NavLink></li>
13+
</ul>
14+
15+
{/* add this */}
16+
{this.props.children}
17+
18+
</div>
19+
)
620
}
721
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// modules/NavLink.js
2+
import React from 'react'
3+
import { Link } from 'react-router'
4+
5+
export default React.createClass({
6+
render() {
7+
return <Link {...this.props} activeClassName="active"/>
8+
}
9+
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// modules/Repos.js
2+
import React from 'react'
3+
import { Link } from 'react-router'
4+
// ...
5+
export default React.createClass({
6+
render() {
7+
return (
8+
<div>
9+
<h2>Repos</h2>
10+
11+
{/* add some links */}
12+
<ul>
13+
<li><Link to="/repos/reactjs/react-router">React Router</Link></li>
14+
<li><Link to="/repos/facebook/react">React</Link></li>
15+
</ul>
16+
17+
</div>
18+
)
19+
}
20+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
3+
export default React.createClass({
4+
render() {
5+
return (
6+
<div>
7+
{/*<h2>{this.props.params.user}</h2>*/}
8+
<h2>{this.props.params.sig}</h2>
9+
</div>
10+
)
11+
}
12+
})

0 commit comments

Comments
 (0)