The library for web and native user interfaces.
Remove React.autoBind from examples
Paul O’Shannessy committed
Jul 17, 2013 at 11:32 UTC
0c1f2720b38acf1b8968eac46ab887add37ee253
4 files changed
+29
-29
examples/ballmer-peak/example.js
+2
-2
@@ -14,9 +14,9 @@ var BallmerPeakCalculator = React.createClass({
14
getInitialState: function() {
15
return {bac: 0};
16
},
17
- handleChange: React.autoBind(function() {
17
+ handleChange: function() {
18
this.setState({bac: this.refs.bac.getDOMNode().value});
19
- }),
19
+ },
20
render: function() {
21
var bac;
22
var pct;
examples/jquery-bootstrap/js/app.js
+9
-9
@@ -67,18 +67,18 @@ var BootstrapModal = React.createClass({
67
</div>
68
);
69
},
70
- onCancel: React.autoBind(function() {
70
+ onCancel: function() {
71
if (this.props.onCancel) {
72
this.props.onCancel();
73
}
74
this.close();
75
- }),
76
- onConfirm: React.autoBind(function() {
75
+ },
76
+ onConfirm: function() {
77
if (this.props.onConfirm) {
78
this.props.onConfirm();
79
}
80
this.close();
81
- }),
81
+ },
82
close: function() {
83
if (this.props.onClose) {
84
this.props.onClose();
@@ -90,14 +90,14 @@ var Example = React.createClass({
90
getInitialState: function() {
91
return {modalVisible: false};
92
},
93
- toggleModal: React.autoBind(function() {
93
+ toggleModal: function() {
94
this.setState({modalVisible: !this.state.modalVisible});
95
- }),
96
- handleCancel: React.autoBind(function() {
95
+ },
96
+ handleCancel: function() {
97
if (confirm('Are you sure you want to cancel?')) {
98
this.toggleModal();
99
}
100
- }),
100
+ },
101
render: function() {
102
var modal = null;
103
if (this.state.modalVisible) {
@@ -121,4 +121,4 @@ var Example = React.createClass({
121
}
122
});
123
124
-React.renderComponent(<Example />, document.getElementById('jqueryexample'));
\ No newline at end of file
124
+React.renderComponent(<Example />, document.getElementById('jqueryexample'));
examples/todomvc-backbone/js/app.js
+10
-10
@@ -74,17 +74,17 @@ var Utils = {
74
// Begin React stuff
75
76
var TodoItem = React.createClass({
77
- handleSubmit: React.autoBind(function(event) {
77
+ handleSubmit: function(event) {
78
var val = this.refs.editField.getDOMNode().value;
79
if (val) {
80
this.props.onSave(val);
81
}
82
return false;
83
- }),
84
- onEdit: React.autoBind(function() {
83
+ },
84
+ onEdit: function() {
85
this.props.onEdit();
86
this.refs.editField.getDOMNode().focus();
87
- }),
87
+ },
88
render: function() {
89
return (
90
<li class={cx({completed: this.props.todo.get('completed'), editing: this.props.editing})}>
@@ -166,7 +166,7 @@ var TodoApp = React.createClass({
166
getBackboneModels: function() {
167
return [this.props.todos];
168
},
169
- handleSubmit: React.autoBind(function() {
169
+ handleSubmit: function() {
170
var val = this.refs.newField.getDOMNode().value.trim();
171
if (val) {
172
this.props.todos.create({
@@ -177,13 +177,13 @@ var TodoApp = React.createClass({
177
this.refs.newField.getDOMNode().value = '';
178
}
179
return false;
180
- }),
181
- toggleAll: React.autoBind(function(event) {
180
+ },
181
+ toggleAll: function(event) {
182
var checked = event.nativeEvent.target.checked;
183
this.props.todos.map(function(todo) {
184
todo.set('completed', checked);
185
});
186
- }),
186
+ },
187
destroy: function(todo) {
188
this.props.todos.remove(todo);
189
},
@@ -194,11 +194,11 @@ var TodoApp = React.createClass({
194
todo.set('title', text);
195
this.setState({editing: null});
196
},
197
- clearCompleted: React.autoBind(function() {
197
+ clearCompleted: function() {
198
this.props.todos.completed().map(function(todo) {
199
todo.destroy();
200
});
201
- }),
201
+ },
202
render: function() {
203
var footer = null;
204
var main = null;
examples/todomvc/js/app.js
+8
-8
@@ -32,24 +32,24 @@ function cx(obj) {
32
}
33
34
var TodoItem = React.createClass({
35
- handleSubmit: React.autoBind(function() {
35
+ handleSubmit: function() {
36
var val = this.state.editText;
37
if (val) {
38
this.props.onSave(val);
39
this.setState({editField: ''});
40
}
41
return false;
42
- }),
43
- handleEdit: React.autoBind(function() {
42
+ },
43
+ handleEdit: function() {
44
this.props.onEdit();
45
this.refs.editField.getDOMNode().focus();
46
- }),
47
- handleKey: React.autoBind(function(event) {
46
+ },
47
+ handleKey: function(event) {
48
if (event.nativeEvent.keyCode === 27) {
49
this.handleSubmit();
50
}
51
this.setState({editText: event.target.value});
52
- }),
52
+ },
53
getInitialState: function() {
54
return {editText: this.props.todo.title};
55
},
@@ -114,7 +114,7 @@ var TodoApp = React.createClass({
114
};
115
},
116
117
- handleSubmit: React.autoBind(function() {
117
+ handleSubmit: function() {
118
var val = this.refs.newField.getDOMNode().value.trim();
119
if (val) {
120
var todos = this.state.todos;
@@ -127,7 +127,7 @@ var TodoApp = React.createClass({
127
this.refs.newField.getDOMNode().value = '';
128
}
129
return false;
130
- }),
130
+ },
131
132
toggleAll: function(event) {
133
var checked = event.nativeEvent.target.checked;