Skip to content

Commit 4406486

Browse files
committed
fix: Not saving done/undone tasks on localStorage...
1 parent 8cdeb49 commit 4406486

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/TodoApp.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ const todoReducer = (state, action) => {
3838
let temp;
3939
switch (action.type) {
4040
case 'do':
41-
return state.map((todo) => {
41+
temp = state.map((todo) => {
4242
if (todo.id === action.id) return { ...todo, complete: true };
4343
return todo;
4444
});
45+
localStorage.setItem('solvoyo-todo', JSON.stringify(temp));
46+
return temp;
4547
case 'undo':
46-
return state.map((todo) => {
48+
temp = state.map((todo) => {
4749
if (todo.id === action.id) return { ...todo, complete: false };
4850
return todo;
4951
});
52+
localStorage.setItem('solvoyo-todo', JSON.stringify(temp));
53+
return temp;
5054
case 'add':
5155
temp = state.concat({
5256
task: action.task,

0 commit comments

Comments
 (0)