diff --git a/src/App.jsx b/src/App.jsx
index c869b09..e41ae79 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -3,11 +3,25 @@ import TodoList from './TodoList.jsx'
import TodoAddForm from './TodoAddForm.jsx'
class TodoApp extends React.Component {
+ state = {
+ todos:[],
+ }
+ addTodo = (val) =>{
+ this.state.todos.push(val);
+ this.setState({todos:this.state.todos});
+ }
+ removeTodo = (id) => {
+ this.state.todos.splice(id,1);
+ this.setState({todos:this.state.todos});
+ }
+
+
render() {
return (
Todo App
- 123
+
+
);
}
diff --git a/src/TodoAddForm.jsx b/src/TodoAddForm.jsx
index fbf6003..0e68251 100644
--- a/src/TodoAddForm.jsx
+++ b/src/TodoAddForm.jsx
@@ -1,15 +1,27 @@
import React from 'react'
class TodoAddForm extends React.Component {
- state = {
- inputText: ''
+ constructor(props){
+ super(props)
+ this.state = {
+ inputText: ''
+ }
}
+ handleChange= (event)=> {
+ this.setState({inputText: event.target.value});
+ }
+
+ addTodo = () =>{
+ this.props.addTodo(this.state.inputText);
+ this.setState({inputText:''});
+ }
+
render() {
return (
-
-
+
+
);
}
diff --git a/src/TodoItem.jsx b/src/TodoItem.jsx
index 170af86..ae49077 100644
--- a/src/TodoItem.jsx
+++ b/src/TodoItem.jsx
@@ -1,10 +1,21 @@
import React from 'react'
class TodoItem extends React.Component {
+ constructor(props){
+ super(props)
+ }
+ removeTodo = () => {
+ this.props.removeTodo(this.props.position);
+ console.log(this.props.position);
+ }
+
render() {
return (
-
+
+ - {this.props.todo}
+

+
);
}
diff --git a/src/TodoList.jsx b/src/TodoList.jsx
index d588dc4..fdde84a 100644
--- a/src/TodoList.jsx
+++ b/src/TodoList.jsx
@@ -2,10 +2,17 @@ import React from 'react'
import TodoItem from './TodoItem.jsx'
class TodoList extends React.Component {
+ constructor(props){
+ super(props)
+ }
render() {
return (
-
+ {this.props.todos.map((todo,i)=>{
+ return(
+
+ );
+ })}
);
}