This repository was archived by the owner on Jul 19, 2019. It is now read-only.
File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import React from 'react'
2
2
3
3
export default React . createClass ( {
4
4
render ( ) {
5
+ const { userName, repoName } = this . props . params
5
6
return (
6
7
< div >
7
- < h2 > { this . props . params . repoName } </ h2 >
8
+ < h2 > { userName } / { repoName } </ h2 >
8
9
</ div >
9
10
)
10
11
}
Original file line number Diff line number Diff line change @@ -2,13 +2,32 @@ 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
+ } ,
16
+
5
17
render ( ) {
6
18
return (
7
19
< div >
8
20
< h2 > Repos</ h2 >
9
21
< ul >
10
22
< li > < NavLink to = "/repos/rackt/react-router" > React Router</ NavLink > </ li >
11
23
< 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 >
12
31
</ ul >
13
32
{ this . props . children }
14
33
</ div >
You can’t perform that action at this time.
0 commit comments