Commit be233669 authored by Mark Florian's avatar Mark Florian

Merge branch 'docs-fix-vuex-complex-state-example' into 'master'

Fix Vuex "Updating complex state" docs example

See merge request gitlab-org/gitlab!42141
parents cc2070a9 bf2ef24f
...@@ -216,12 +216,15 @@ A mutation written like this is harder to maintain and more error prone. We shou ...@@ -216,12 +216,15 @@ A mutation written like this is harder to maintain and more error prone. We shou
// Good // Good
export default { export default {
[types.MARK_AS_CLOSED](state, itemId) { [types.MARK_AS_CLOSED](state, itemId) {
const item = state.items.find(i => i.id == itemId); const item = state.items.find(x => x.id === itemId);
Vue.set(item, 'closed', true)
state.items.splice(index, 1, item) if (!item) {
} return;
} }
Vue.set(item, 'closed', true);
},
};
``` ```
This approach is better because: This approach is better because:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment