I want to access topicCategories
in child component. I've tried $this.$parent.$parent.topicCategories
but it is undefined, even though i can see it in console?
So i tried the below method but this only shows topicCategories
of the previous page not the current page. So first time you view a post, it is empty, then the next post, you see the topicCategories
of the previous post.
parent (post.vue)
this.topicCategories = this.Categories.map((category: any) => category.id);
this.$store.dispatch('app/setCurrentCategories', topicCategories);
child component (read.vue)
if(this.$store.state.app.currentCategories.length) {
const categories = this.$store.state.app.currentCategories.map((category: any) => category.id);
}
How do i get topicCategories
in the child component of the current page?