2 ms·
> know (and interact) with their parent components directly Do you have that backwards, or is there something I'm missing? In React it's easy for child compone
by stickfigure 6y ago
> know (and interact) with their parent components directly
Do you have that backwards, or is there something I'm missing? In React it's easy for child components to interact with their parents by calling callbacks. What's hard is to call methods on children and interact with their state... the answer is always "lift state up".
- Rodeoclash 6y agoThat's correct. However in Vue I have access to $this.parent which is an instance of the parent component. My child component can read data directly from it, even modify state of the parent by reassigning values.
- jnwr 6y agoImportant note here is using $parent is bad form and discouraged in the vue docs[0] 0. https://vuejs.org/v2/style-guide/#Implicit-parent-child-communication-use-with-caution https://vuejs.org/v2/style-guide/#Implicit-parent-child-comm...