I'm going round in circles here.
I have a vuejs2 app up and running with typescript but hitting an error when i try to pass data to a child component that originates from the store.
<template>
<div>
<form-error :error422.sync="errors"></form-error>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import FormError from '@/components/FormError422.vue';
import cloneObj from '@/utils/cloneObj';
@Component({
components: {
FormError,
},
})
export default class RegisterForm extends Vue {
get errors() {
return cloneObj(AuthenticationModule.errorRegister);
}
</script>
The child
<template>
<div>
{{error422.errors}}
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { Generic422 } from '@/ms-authentication'
@Component
export default class FormError422 extends Vue {
@Prop() private error422: Generic422 = {
errors: [],
};
}
</script>
But whatever i do it throws a warning:
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "error422"