[Vuejs]-Problem with commiting a mutator to vuex store

0👍

I’m guessing that boardDetails is an object, which are passed by reference in JS, so the object that gets added to the boards array in the store is the same one that’s holding the form state in your component.

When you call resetValues(), you’re probably setting the boardDetails object’s properties back to their defaults, which is also reflected in the store (as it’s the same object in both).

You could fix this by creating a new payload object with the form values:

this.$store.commit("addBoard", { ...this.boardDetails })

Leave a comment