DEV Community

Discussion on: Getting around prop immutability in Vue.js

Collapse
syylaurence profile image
Laurence Ivan Sy

Thank you, this is very helpful in modifying the props of the parent.

I would like to add, you can store the prop on local state and then you can modify the data on the local state.

props : {
     skillsToMerge : {
          required: true,
          type: Array,
          default: () => []
     }
},

data : function () {
     my_skillsToMerge : this.skillsToMerge,
},

methods : {
      alterSkills : function () {
           // modify this.my_skillsToMerge here   
      }
},
Enter fullscreen mode Exit fullscreen mode

Ref: vuejs.org/v2/guide/state-managemen...

Collapse
reynoldadade profile image
Reynold Osei Adade Author

This is very interesting, i will implement this and see the possibilties, thank you for this