diff --git a/src/App.js b/src/App.js index 93d4b5e..0817069 100644 --- a/src/App.js +++ b/src/App.js @@ -1,18 +1,59 @@ import React, { Component } from 'react'; import ToDoListItem from "./ToDoListItem.js" +import "./ToDoListItem.css" import './App.css'; class App extends Component { + constructor(props) { + super(props); + this.state = { items: [], title: '', description: '' }; + this.handleSubmit = this.handleSubmit.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 (