diff --git a/db.json b/db.json index b7b09cf..7eab90a 100644 --- a/db.json +++ b/db.json @@ -1,30 +1,34 @@ { - "tasks": - [ - { - "id": 1, - "title": "Buy groceries", - "completed": false - }, - { - "id": 2, - "title": "Finish React project", - "completed": false - }, - { - "id": 3, - "title": "Call the bank", - "completed": true - }, - { - "id": 4, - "title": "Walk the dog", - "completed": false - }, - { - "id": 5, - "title": "Read a book", - "completed": true - } - ] + "tasks": [ + { + "id": "1", + "title": "Buy groceries", + "completed": false + }, + { + "id": "2", + "title": "Finish React project", + "completed": false + }, + { + "id": "3", + "title": "Call the bank", + "completed": false + }, + { + "id": "4", + "title": "Walk the dog", + "completed": false + }, + { + "id": "5", + "title": "Read a book", + "completed": false + }, + { + "id": "0526", + "title": "Exercise", + "completed": false + } + ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d365b3d..52e8957 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "technical-lesson-react-hooks-task-manager", + "name": "react-hooks-task-manager-lab", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "technical-lesson-react-hooks-task-manager", + "name": "react-hooks-task-manager-lab", "version": "0.0.0", "dependencies": { "@vitejs/plugin-react": "^4.3.4", diff --git a/src/components/App.jsx b/src/components/App.jsx index 9394aab..48693a5 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -4,14 +4,14 @@ import TaskForm from "./TaskForm"; import SearchBar from "./SearchBar"; function App() { - const [tasks, setTasks] = useState([]); + const { tasks, setTasks } = useContext(TaskContext); useEffect(() => { fetch('http://localhost:6001/tasks') - .then(r=>r.json()) - .then(data=>setTasks(data)) - - }, []); + .then(r => r.json()) + .then(data => setTasks(data)) + + }, [setTasks]); return (