I was trying to build a tab component in Angular and Vue. Vue screamed (threw an error in the console) when I changed the component's props. Angular seems fine with it.
<tab [active]="true"></tab>
export class TabComponent implements OnInit {
@Input() name: string;
@Input() active = false;
ngOnInit() {
// Here I am mutatating an input property which is bad because,
// further changes to that input doesn't take effect
this.active = false;
console.log({name: this.name, active: this.active});
}
}
I personally think it's not right to modify a component's input property. My question is why the Angular team doesn't enforce that by throwing an error in the console.
Vue will display this message
vue.js:634 [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: "selected"