Skip to content

Commit

Permalink
➕ feat: uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Linder Hassinger committed Apr 11, 2024
1 parent 351998b commit 12a2243
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 14 additions & 1 deletion semana-9/todolist/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion semana-9/todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/react": "^18.2.66",
Expand Down
3 changes: 2 additions & 1 deletion semana-9/todolist/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { DeleteForm, InputTask, Modal, UpdateForm } from "./components";
import { tasks, saveTasksInLocalStorage } from "./utils";
import { v4 as uuidv4 } from "uuid";

export default function App() {
// Es el estado de la lista de tareas
Expand All @@ -19,7 +20,7 @@ export default function App() {
};

const handleListTask = (task) => {
task.id = listTasks.length + 1;
task.id = uuidv4();
const newTasks = [...listTasks, task];
setListTask(newTasks);
saveTasksInLocalStorage(newTasks);
Expand Down

0 comments on commit 12a2243

Please sign in to comment.