|
@@ -2,6 +2,18 @@ import React from 'react'
|
|
import NavLink from './NavLink'
|
|
import NavLink from './NavLink'
|
|
|
|
|
|
export default React.createClass({
|
|
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() {
|
|
render() {
|
|
return (
|
|
return (
|
|
<div>
|
|
<div>
|
|
@@ -9,6 +21,13 @@ export default React.createClass({
|
|
<ul>
|
|
<ul>
|
|
<li><NavLink to="/repos/rackt/react-router">React Router</NavLink></li>
|
|
<li><NavLink to="/repos/rackt/react-router">React Router</NavLink></li>
|
|
<li><NavLink to="/repos/facebook/react">React</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>
|
|
</ul>
|
|
{this.props.children}
|
|
{this.props.children}
|
|
</div>
|
|
</div>
|