forked from reactjs/react-router-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepos.js
36 lines (33 loc) · 962 Bytes
/
Repos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React from 'react'
import NavLink from './NavLink'
export default React.createClass({
contextTypes: {
router: React.PropTypes.object
},
handleSubmit(event) {
event.preventDefault()
const userName = event.target.elements[0].value
const repo = event.target.elements[1].value
const path = `/repos/${userName}/${repo}`
this.context.router.push(path)
},
render() {
return (
<div>
<h2>Repos</h2>
<ul>
<li><NavLink to="/repos/reactjs/react-router">React Router</NavLink></li>
<li><NavLink to="/repos/facebook/react">React</NavLink></li>
<li>
<form onSubmit={this.handleSubmit}>
<input type="text" placeholder="userName"/> / {' '}
<input type="text" placeholder="repo"/>{' '}
<button type="submit">Go</button>
</form>
</li>
</ul>
{this.props.children}
</div>
)
}
})