File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,13 @@ import NavLink from './NavLink';
13
13
14
14
class Repos extends React .Component {
15
15
16
- // add this method
16
+ // add this method and handleSubmit below
17
+ constructor () {
18
+ super ();
19
+ this .handleSubmit = this .handleSubmit .bind (this );
20
+ }
21
+
22
+ // add this method too
17
23
handleSubmit (event ) {
18
24
event .preventDefault ();
19
25
const userName = event .target .elements [0 ].value ;
@@ -45,6 +51,9 @@ class Repos extends React.Component{
45
51
}
46
52
```
47
53
54
+ View the page and test the form submission. We won't make any further changes
55
+ to the code in this lesson, but we'll look at how navigate programmatically.
56
+
48
57
There are two ways you can do this, the first is simpler than the
49
58
second.
50
59
@@ -80,7 +89,7 @@ class Router extends React.Component {
80
89
81
90
handleSubmit (event ) {
82
91
// ...
83
- this .context .router .push (path)
92
+ this .context .router .push (path);
84
93
}
85
94
86
95
// ..
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ import Repos from './Repos';
94
94
import Repo from ' ./Repo' ;
95
95
import Home from ' ./Home' ;
96
96
97
- module . exports = (
97
+ export default (
98
98
< Route path= " /" component= {App}>
99
99
< IndexRoute component= {Home}/ >
100
100
< Route path= " /repos" component= {Repos}>
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import NavLink from './NavLink';
3
3
4
4
class Repos extends React . Component {
5
5
6
+ constructor ( ) {
7
+ super ( ) ;
8
+ this . handleSubmit = this . handleSubmit . bind ( this ) ;
9
+ }
10
+
6
11
handleSubmit ( event ) {
7
12
event . preventDefault ( ) ;
8
13
const userName = event . target . elements [ 0 ] . value ;
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import NavLink from './NavLink';
3
3
4
4
class Repos extends React . Component {
5
5
6
+ constructor ( ) {
7
+ super ( ) ;
8
+ this . handleSubmit = this . handleSubmit . bind ( this ) ;
9
+ }
10
+
6
11
handleSubmit ( event ) {
7
12
event . preventDefault ( ) ;
8
13
const userName = event . target . elements [ 0 ] . value ;
You can’t perform that action at this time.
0 commit comments