Kaynağa Gözat

-itemsCompleted | itemsCurrent from state

ilya_shyian 3 yıl önce
ebeveyn
işleme
3b528e5a23
1 değiştirilmiş dosya ile 3 ekleme ve 4 silme
  1. 3 4
      src/components/TodoList.js

+ 3 - 4
src/components/TodoList.js

@@ -1,11 +1,11 @@
 import React from "react";
 import ListItem from "./ListItem";
-import { getTodoList, createNewItem, updateItem, deleteItem } from "../static/js/api";
+import { getTodoList, createNewItem } from "../static/js/api";
 
 export default class TodoList extends React.Component {
     constructor(props) {
         super(props);
-        this.state = { items: [], itemsCompleted: [], itemsCurrent: [], inputText: "" };
+        this.state = { items: [], inputText: "" };
 
         this.handleChange = this.handleChange.bind(this);
         this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -13,7 +13,7 @@ export default class TodoList extends React.Component {
         this.deleteItem = this.deleteItem.bind(this);
         this.completeItem = this.completeItem.bind(this);
     }
-    componentDidMount() {
+    useEffect() {
         getTodoList().then((data) => {
             this.setState({
                 items: data,
@@ -147,7 +147,6 @@ export default class TodoList extends React.Component {
     }
 
     handleKeyDown(e) {
-
         if (e.key === "Enter") {
             this.addItem(e);
         }