Commit 0af300fe authored by Pascal Hartig's avatar Pascal Hartig

React: Upgrade app to 0.12

- Remove obsolete @jsx annotations
- Rename renderComponent -> render
- Use event.preventDefault instead of returning false
parent 29a6fae9
/**
* @jsx React.DOM
*/
/*jshint quotmark:false */ /*jshint quotmark:false */
/*jshint white:false */ /*jshint white:false */
/*jshint trailing:false */ /*jshint trailing:false */
...@@ -42,14 +39,14 @@ var app = app || {}; ...@@ -42,14 +39,14 @@ var app = app || {};
return; return;
} }
event.preventDefault();
var val = this.refs.newField.getDOMNode().value.trim(); var val = this.refs.newField.getDOMNode().value.trim();
if (val) { if (val) {
this.props.model.addTodo(val); this.props.model.addTodo(val);
this.refs.newField.getDOMNode().value = ''; this.refs.newField.getDOMNode().value = '';
} }
return false;
}, },
toggleAll: function (event) { toggleAll: function (event) {
...@@ -171,7 +168,7 @@ var app = app || {}; ...@@ -171,7 +168,7 @@ var app = app || {};
var model = new app.TodoModel('react-todos'); var model = new app.TodoModel('react-todos');
function render() { function render() {
React.renderComponent( React.render(
<TodoApp model={model}/>, <TodoApp model={model}/>,
document.getElementById('todoapp') document.getElementById('todoapp')
); );
......
/**
* @jsx React.DOM
*/
/*jshint quotmark:false */ /*jshint quotmark:false */
/*jshint white:false */ /*jshint white:false */
/*jshint trailing:false */ /*jshint trailing:false */
......
/**
* @jsx React.DOM
*/
/*jshint quotmark: false */ /*jshint quotmark: false */
/*jshint white: false */ /*jshint white: false */
/*jshint trailing: false */ /*jshint trailing: false */
...@@ -15,7 +12,7 @@ var app = app || {}; ...@@ -15,7 +12,7 @@ var app = app || {};
var ENTER_KEY = 13; var ENTER_KEY = 13;
app.TodoItem = React.createClass({ app.TodoItem = React.createClass({
handleSubmit: function () { handleSubmit: function (event) {
var val = this.state.editText.trim(); var val = this.state.editText.trim();
if (val) { if (val) {
this.props.onSave(val); this.props.onSave(val);
...@@ -23,7 +20,6 @@ var app = app || {}; ...@@ -23,7 +20,6 @@ var app = app || {};
} else { } else {
this.props.onDestroy(); this.props.onDestroy();
} }
return false;
}, },
handleEdit: function () { handleEdit: function () {
...@@ -42,9 +38,9 @@ var app = app || {}; ...@@ -42,9 +38,9 @@ var app = app || {};
handleKeyDown: function (event) { handleKeyDown: function (event) {
if (event.which === ESCAPE_KEY) { if (event.which === ESCAPE_KEY) {
this.setState({editText: this.props.todo.title}); this.setState({editText: this.props.todo.title});
this.props.onCancel(); this.props.onCancel(event);
} else if (event.which === ENTER_KEY) { } else if (event.which === ENTER_KEY) {
this.handleSubmit(); this.handleSubmit(event);
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment