From 3da4ab2987b5e7743e607b254ca3642df5a0414d Mon Sep 17 00:00:00 2001 From: Tony Spiro Date: Thu, 22 Oct 2015 10:36:36 -0500 Subject: [PATCH 1/2] todo undo - add change from click to on submit --- .../todos-with-undo/components/AddTodo.js | 21 ++++++++++++------- examples/todos-with-undo/containers/App.js | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/todos-with-undo/components/AddTodo.js b/examples/todos-with-undo/components/AddTodo.js index fdc2ae5c2e..785c6122c5 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))} /> From 92105be88398fd658e438b88bca56b806c1263cd Mon Sep 17 00:00:00 2001 From: Tony Spiro Date: Thu, 22 Oct 2015 11:56:21 -0500 Subject: [PATCH 2/2] lint fixes --- examples/todos-with-undo/components/AddTodo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todos-with-undo/components/AddTodo.js b/examples/todos-with-undo/components/AddTodo.js index 785c6122c5..0391fa2908 100644 --- a/examples/todos-with-undo/components/AddTodo.js +++ b/examples/todos-with-undo/components/AddTodo.js @@ -5,7 +5,7 @@ export default class AddTodo extends Component { e.preventDefault(); const node = this.refs.input; const text = node.value.trim(); - if(text){ + if (text) { this.props.onAddSubmit(text); node.value = ''; }