I have a component which takes a property called 'endpoints' from the store, adjusts it slightly...
computed: {
...mapState(['endpoints']),
adjustedEndpoints () {
if (this.endpoints){
return this.endpoints.map(x => {
x.displayName = x.name;
return x;
})
}
},
...and passes it to a table component in the template:
<b-table show-empty
stacked="md"
:items="adjustedEndpoints"
:fields="fields"
:current-page="currentPage"
:per-page="perPage"
:filter="filter"
:sort-by.sync="sortBy"
:sort-desc.sync="sortDesc"
:sort-direction="sortDirection"
@filtered="onFiltered"
>
The issue is that when I edit an endpoint's properties, I see it change in the Vue component state, but this is not reflected in the rendered component until reload. I am guessing that the adjustedEndpoints() function is not being called automatically.
How can I fix this?
displayNamepart of each endpoint before your computed runs?this.$set(x, 'displayName', x.name).adjustedEndpointstob-table. If I understand correctly, for now, the first render, that renders correctly and the displayName gets to theb-tableand renders as you expect. Then, at some point, you change anendpoint, but theb-tabledoesn't update the way you expect? If that is the case, how exactly do you change theendpoint? I ask because, as mentioned above, Vue cannot always detect changes to an object or an array depending on how you update it which means thatadjustedEndointsmay not run after you change endpoint.