Skip to content

Commit e8449b2

Browse files
committed
Fix ES6 constructor for handleSubmit in lessons 12-14
1 parent c1cf0fe commit e8449b2

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

lessons/12-navigating/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import NavLink from './NavLink';
1313

1414
class Repos extends React.Component{
1515

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
1723
handleSubmit(event) {
1824
event.preventDefault();
1925
const userName = event.target.elements[0].value;
@@ -45,6 +51,9 @@ class Repos extends React.Component{
4551
}
4652
```
4753

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+
4857
There are two ways you can do this, the first is simpler than the
4958
second.
5059

@@ -80,7 +89,7 @@ class Router extends React.Component {
8089

8190
handleSubmit(event) {
8291
// ...
83-
this.context.router.push(path)
92+
this.context.router.push(path);
8493
}
8594

8695
// ..

lessons/13-server-rendering/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import Repos from './Repos';
9494
import Repo from './Repo';
9595
import Home from './Home';
9696

97-
module.exports = (
97+
export default (
9898
<Route path="/" component={App}>
9999
<IndexRoute component={Home}/>
100100
<Route path="/repos" component={Repos}>

lessons/13-server-rendering/modules/Repos.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import NavLink from './NavLink';
33

44
class Repos extends React.Component {
55

6+
constructor() {
7+
super();
8+
this.handleSubmit = this.handleSubmit.bind(this);
9+
}
10+
611
handleSubmit(event) {
712
event.preventDefault();
813
const userName = event.target.elements[0].value;

lessons/14-whats-next/modules/Repos.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import NavLink from './NavLink';
33

44
class Repos extends React.Component {
55

6+
constructor() {
7+
super();
8+
this.handleSubmit = this.handleSubmit.bind(this);
9+
}
10+
611
handleSubmit(event) {
712
event.preventDefault();
813
const userName = event.target.elements[0].value;

0 commit comments

Comments
 (0)