Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit 9bca0e5

Browse files
committed
Lesson 12 Final
1 parent 7f33684 commit 9bca0e5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

modules/Repo.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React from 'react'
22

33
export default React.createClass({
44
render() {
5+
const { userName, repoName } = this.props.params
56
return (
67
<div>
7-
<h2>{this.props.params.repoName}</h2>
8+
<h2>{userName} / {repoName}</h2>
89
</div>
910
)
1011
}

modules/Repos.js

+19
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,32 @@ import React from 'react'
22
import NavLink from './NavLink'
33

44
export default React.createClass({
5+
contextTypes: {
6+
router: React.PropTypes.object
7+
},
8+
9+
handleSubmit(event) {
10+
event.preventDefault()
11+
const userName = event.target.elements[0].value
12+
const repo = event.target.elements[1].value
13+
const path = `/repos/${userName}/${repo}`
14+
this.context.router.push(path)
15+
},
16+
517
render() {
618
return (
719
<div>
820
<h2>Repos</h2>
921
<ul>
1022
<li><NavLink to="/repos/rackt/react-router">React Router</NavLink></li>
1123
<li><NavLink to="/repos/facebook/react">React</NavLink></li>
24+
<li>
25+
<form onSubmit={this.handleSubmit}>
26+
<input type="text" placeholder="userName"/> / {' '}
27+
<input type="text" placeholder="repo"/>{' '}
28+
<button type="submit">Go</button>
29+
</form>
30+
</li>
1231
</ul>
1332
{this.props.children}
1433
</div>

0 commit comments

Comments
 (0)