Skip to content

Commit e64dc7c

Browse files
committed
Use Unshift instead of Push ⏩
1 parent ac4c1c3 commit e64dc7c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/components/Main/CreateTodo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class CreateTodoContainer extends React.Component {
102102
variables: { id: productId, completed: status === "DONE" },
103103
});
104104
const todos = data.product.todos.map(t => t); // make a shallow copy otherwise error "Object is not extensible" is thrown
105-
todos.push(createTodo);
105+
todos.unshift(createTodo);
106106
const newData = {
107107
...data,
108108
product: { ...data.product, todos },

src/components/Main/TodoBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class TodoBoxContainer extends React.Component {
102102
});
103103

104104
const todos2 = cacheData2.product.todos.map(t => t); // make a shallow copy otherwise error "Object is not extensible" is thrown
105-
todos2.push({
105+
todos2.unshift({
106106
...data[completed ? "uncompleteTodo" : "completeTodo"],
107107
id: todo.id,
108108
completed_at,

0 commit comments

Comments
 (0)