diff --git a/examples/todos-with-undo/components/AddTodo.js b/examples/todos-with-undo/components/AddTodo.js index fdc2ae5c2e..0391fa2908 100644 --- a/examples/todos-with-undo/components/AddTodo.js +++ b/examples/todos-with-undo/components/AddTodo.js @@ -1,25 +1,30 @@ import React, { Component, PropTypes } from 'react'; export default class AddTodo extends Component { - handleClick() { + handleSubmit(e) { + e.preventDefault(); const node = this.refs.input; const text = node.value.trim(); - this.props.onAddClick(text); - node.value = ''; + if (text) { + this.props.onAddSubmit(text); + node.value = ''; + } } render() { return (
- - +
this.handleSubmit(e)}> + + +
); } } AddTodo.propTypes = { - onAddClick: PropTypes.func.isRequired + onAddSubmit: PropTypes.func.isRequired }; diff --git a/examples/todos-with-undo/containers/App.js b/examples/todos-with-undo/containers/App.js index 5b8b445dd1..b59e7007c1 100644 --- a/examples/todos-with-undo/containers/App.js +++ b/examples/todos-with-undo/containers/App.js @@ -12,7 +12,7 @@ class App extends Component { return (
dispatch(addTodo(text))} /> + onAddSubmit={text => dispatch(addTodo(text))} /> dispatch(completeTodo(index))} />