@samitouri / QOS-React-2 / commits / 7795968382
Fork 0

The library for web and native user interfaces.

Consistently use autoBind on homepage examples

Except for todo.js, all the other examples on the homepage use React.autoBind when defining event handler methods. Test Plan: Added todo items successfully

David Hu committed Jun 2, 2013 at 12:04 UTC 779596838240086a32e8bc60d66e5161ce7add66
1 file changed +6 -6
docs/_js/examples/todo.js
+6 -6
@@ -14,15 +14,15 @@ var TodoList = React.createClass({\n\
14 });\n\
15 \n\
16 var TodoCreate = React.createClass({\n\
17 - handleSubmit: function() {\n\
17 + handleSubmit: React.autoBind(function() {\n\
18 var textInput = this.refs.textInput.getDOMNode();\n\
19 this.props.onCreate(textInput.value);\n\
20 textInput.value = '';\n\
21 return false;\n\
22 - },\n\
22 + }),\n\
23 render: function() {\n\
24 return (\n\
25 - <form onSubmit={this.handleSubmit.bind(this)}>\n\
25 + <form onSubmit={this.handleSubmit}>\n\
26 <input type=\"text\" ref=\"textInput\" />\n\
27 <button>Add</button>\n\
28 </form>\n\
@@ -34,15 +34,15 @@ var TodoApp = React.createClass({\n\
34 getInitialState: function() {\n\
35 return {items: []};\n\
36 },\n\
37 - onItemCreate: function(value) {\n\
37 + onItemCreate: React.autoBind(function(value) {\n\
38 this.setState({items: this.state.items.concat([value])});\n\
39 - },\n\
39 + }),\n\
40 render: function() {\n\
41 return (\n\
42 <div>\n\
43 <h3>TODO</h3>\n\
44 <TodoList items={this.state.items} />\n\
45 - <TodoCreate onCreate={this.onItemCreate.bind(this)} />\n\
45 + <TodoCreate onCreate={this.onItemCreate} />\n\
46 </div>\n\
47 );\n\
48 }\n\