Does any one have a clean way of binding vuex data to inputs, Say you want to hydrate an edit form with data from vuex, if you don't clone it to a local object before v-modeling it to the input you get mutations errors on input.
This gets particular messy with deep objects with arrays inside as a simple {...object} spread does not clone the nested arrays / objects and the nested arrays will still be tied to vuex.
This is what Im finding my self doing a lot
created() {
const productId = this.$route.params.id
this.product = _.find(this.$store.state.vendor.products.list, { id: productId })
this.getProduct(productId).then(response => {
this.product = { ...response }
const clonedVariants = []
this.product.variants.data.forEach(variant => {
clonedVariants.push({...variant})
})
this.product.variants = {}
this.product.variants.data = clonedVariants;
this.freshProduct = true
})
},
_.cloneDeep