File tree Expand file tree Collapse file tree 2 files changed +5018
-0
lines changed Expand file tree Collapse file tree 2 files changed +5018
-0
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,33 @@ import React from 'react'
2
2
import NavLink from './NavLink'
3
3
4
4
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
+ // console.log(path)
16
+ } ,
17
+
5
18
render ( ) {
6
19
return (
7
20
< div >
8
21
< h2 > Repos</ h2 >
9
22
< ul >
10
23
< li > < NavLink to = "/repos/reactjs/react-router" > React Router</ NavLink > </ li >
11
24
< li > < NavLink to = "/repos/facebook/react" > React</ NavLink > </ li >
25
+ < li >
26
+ < form onSubmit = { this . handleSubmit } >
27
+ < input type = "text" placeholder = "userName" /> / { ' ' }
28
+ < input type = "text" placeholder = "repo" /> { ' ' }
29
+ < button type = "submit" > Go</ button >
30
+ </ form >
31
+ </ li >
12
32
</ ul >
13
33
{ this . props . children }
14
34
</ div >
You can’t perform that action at this time.
0 commit comments