From ca3db90b6da55a952756d52c9a18d74d9fa8acad Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Tue, 31 Mar 2020 14:09:43 +0700 Subject: [PATCH 1/7] Update App.js --- src/App.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 93d4b5e..c8e7858 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,18 @@ import ToDoListItem from "./ToDoListItem.js" import './App.css'; class App extends Component { + constructor(props) { + super(props); + this.state = { + todolist: [], + title: '', + description: '' + }; + this.handleTitle = this.handleTitle.bind(this); + this.handleDescription = this.handleDescription.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + this.handleDelete = this.handleDelete.bind(this); + } render() { return (
@@ -15,4 +27,4 @@ class App extends Component { } } -export default App; \ No newline at end of file +export default App; From f6aefd93df0b100a6a5ea94953d9eae61ee6b118 Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Wed, 1 Apr 2020 09:19:12 +0700 Subject: [PATCH 2/7] Update App.js --- src/App.js | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/src/App.js b/src/App.js index c8e7858..5749c4b 100644 --- a/src/App.js +++ b/src/App.js @@ -3,26 +3,54 @@ import ToDoListItem from "./ToDoListItem.js" import './App.css'; class App extends Component { - constructor(props) { + constructor(props) { super(props); - this.state = { - todolist: [], - title: '', - description: '' - }; - this.handleTitle = this.handleTitle.bind(this); - this.handleDescription = this.handleDescription.bind(this); + this.state = { items: [], title: '', description: '' }; this.handleSubmit = this.handleSubmit.bind(this); - this.handleDelete = this.handleDelete.bind(this); - } + this.handleChange = this.handleChange.bind(this); + } + handleChange = e => { + this.setState({[e.target.name]: e.target.value}); + }; + + handleDeleteItem = index =>{ + const item = this.state.items; + item.splice(index,1); + this.setState({items : item}); + } + handleSubmit = e => { + e.preventDefault(); + const item = this.state.items; + item.push({title: this.state.title,description: this.state.description}); + this.setState({items: item,title: '',description: ''}) + }; render() { return (
+
+ + + +
- -
+
); } } From 2223d7e201b42a5b21f10542f2067a317121786a Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Wed, 1 Apr 2020 09:35:16 +0700 Subject: [PATCH 3/7] Update ToDoListItem.js --- src/ToDoListItem.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ToDoListItem.js b/src/ToDoListItem.js index 5af7931..fac5dea 100644 --- a/src/ToDoListItem.js +++ b/src/ToDoListItem.js @@ -2,14 +2,19 @@ import React, { Component } from 'react'; import './ToDoListItem.css'; class ToDoListItem extends Component { + handleDeleteItem = () => { + this.props.onToDoDelete(); + }; render() { - return ( -
-
-
-
- ); - } + if (this.props.list) { + return this.props.list.map((item, index) => ( +
{this.props.deleteHandler(index)}}> +
{item.title}
+
{item.description}
+
+ ); + } + } } -export default ToDoListItem; \ No newline at end of file +export default ToDoListItem; From 51d1471baf13d87e126d31489776380e270a662c Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Wed, 1 Apr 2020 10:10:30 +0700 Subject: [PATCH 4/7] Update ToDoListItem.js --- src/ToDoListItem.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ToDoListItem.js b/src/ToDoListItem.js index fac5dea..d62c70a 100644 --- a/src/ToDoListItem.js +++ b/src/ToDoListItem.js @@ -2,9 +2,6 @@ import React, { Component } from 'react'; import './ToDoListItem.css'; class ToDoListItem extends Component { - handleDeleteItem = () => { - this.props.onToDoDelete(); - }; render() { if (this.props.list) { return this.props.list.map((item, index) => ( From f3446cf1af549b5883a8f3548ccc317f3c7b4dbb Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Wed, 1 Apr 2020 10:25:49 +0700 Subject: [PATCH 5/7] Update App.js --- src/App.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.js b/src/App.js index 5749c4b..0817069 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import ToDoListItem from "./ToDoListItem.js" +import "./ToDoListItem.css" import './App.css'; class App extends Component { From 55a2a9ce4080dee5f3ea5a375a0a8dd046b4d3f6 Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Wed, 1 Apr 2020 10:26:42 +0700 Subject: [PATCH 6/7] Update ToDoListItem.js --- src/ToDoListItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ToDoListItem.js b/src/ToDoListItem.js index d62c70a..17eb298 100644 --- a/src/ToDoListItem.js +++ b/src/ToDoListItem.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import './ToDoListItem.css'; - +import './App.css'; class ToDoListItem extends Component { render() { if (this.props.list) { From c81226f0ddfeda88efe6c16049ce2d648d097520 Mon Sep 17 00:00:00 2001 From: XuanLanhbk <55599200+XuanLanhbk@users.noreply.github.com> Date: Sun, 5 Apr 2020 11:22:54 +0700 Subject: [PATCH 7/7] Update ToDoListItem.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 先生、本当にごめんなさい。 デバッグしました。 --- src/ToDoListItem.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ToDoListItem.js b/src/ToDoListItem.js index 17eb298..68aa0de 100644 --- a/src/ToDoListItem.js +++ b/src/ToDoListItem.js @@ -9,6 +9,7 @@ class ToDoListItem extends Component {
{item.title}
{item.description}
+ ) ); } }