Skip to content

Commit bafa881

Browse files
kiakingktsn
authored andcommitted
refactor: do not mutate mutation payload in the todo app example (#1670)
* refactor: do not mutate mutation payload in the todo app example * refactor: make things a bit easier to read
1 parent e012653 commit bafa881

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/todomvc/store/mutations.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ export const mutations = {
1515
},
1616

1717
editTodo (state, { todo, text = todo.text, done = todo.done }) {
18-
todo.text = text
19-
todo.done = done
18+
const index = state.todos.indexOf(todo)
19+
20+
state.todos.splice(index, 1, {
21+
...todo,
22+
text,
23+
done
24+
})
2025
}
2126
}

0 commit comments

Comments
 (0)