Skip to content

Commit 41ac073

Browse files
author
Brandon Tilley
committed
Mention auto-binding in demo3
1 parent 4e99b2a commit 41ac073

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

demo3/demo3.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ var Timer = React.createClass({
3737
// merged with the current state; we can use `replaceState` instead
3838
// if we don't want to merge.
3939
tick: function() {
40+
// Note that React auto-binds all top-level methods in the
41+
// object passed to `createClass` to the component instance.
42+
// Because of this, `this` inside the `tick` method is
43+
// automatically the component instance, and we didn't have
44+
// to use `this.tick.bind(this)` inside the `setInterval` call.
4045
this.setState({time: this.state.time + 1});
4146
},
4247

0 commit comments

Comments
 (0)