Skip to content

Commit

Permalink
Merge pull request vasanthk#94 from rkrupinski/master
Browse files Browse the repository at this point in the history
Tweaked the paragraph on arrow functions a bit.
  • Loading branch information
vasanthk authored Nov 22, 2017
2 parents a3f5b96 + 91add11 commit 63b229e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions patterns/22.event-handlers.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Switcher extends React.Component {
}
```

The other alternative is to use arrow functions for the onClick prop function assignment,
Arrow functions auto binds the function with `this`.
The other alternative is to use arrow functions for the onClick prop function assignment.
Arrow functions don't affect the context at invocation time (`this` value from the surrounding scope is used).

Facebook by the way recommend the same technique while dealing with functions that need the context of the same component.
The binding in the constructor may be also useful if we pass callbacks down the tree.
Expand All @@ -93,4 +93,4 @@ class Switcher extends React.Component {
console.log(`Button is clicked inside ${ this.state.name }`);
}
}
```
```

0 comments on commit 63b229e

Please sign in to comment.