summaryrefslogtreecommitdiff
path: root/doc/development/fe_guide/vuex.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/fe_guide/vuex.md')
-rw-r--r--doc/development/fe_guide/vuex.md17
1 files changed, 8 insertions, 9 deletions
diff --git a/doc/development/fe_guide/vuex.md b/doc/development/fe_guide/vuex.md
index 9573dd36e63..4badf3f0845 100644
--- a/doc/development/fe_guide/vuex.md
+++ b/doc/development/fe_guide/vuex.md
@@ -55,10 +55,6 @@ export const createStore = () =>
});
```
-_Note:_ Until this
-[RFC](https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/20) is implemented,
-the above will need to disable the `import/prefer-default-export` ESLint rule.
-
### `state.js`
The first thing you should do before writing any code is to design the state.
@@ -220,12 +216,15 @@ A mutation written like this is harder to maintain and more error prone. We shou
// Good
export default {
[types.MARK_AS_CLOSED](state, itemId) {
- const item = state.items.find(i => i.id == itemId);
- Vue.set(item, 'closed', true)
+ const item = state.items.find(x => x.id === itemId);
- state.items.splice(index, 1, item)
- }
-}
+ if (!item) {
+ return;
+ }
+
+ Vue.set(item, 'closed', true);
+ },
+};
```
This approach is better because: