I'm building a tree view using VueJS and I want to save the last clicked item in a store then use this store to show the last clicked item in a component.
I use a computed property in the the component where I want to show the item. The problem is that when the store changes it doesn't affect the computed property in the component.
The relative code is shown in this link: https://jsfiddle.net/eywraw8t/527884/
Vue.component('category-list', {
template: `
<div>
<b>{{selectedCat}}</b>
<ul>
<category v-for='(catg, catgIdx) in categories' :category='catg' :key='catgIdx'
v-on:category-selected='categorySelected'/>
</ul>
</div>
`,
props: {
categories: { type: Array, default: () => [] }
},
computed:{
selectedCat(){
return bookmarksStore.state.selectedCategory
}
}
})