Components’ basic communication
We have seen previously that a parent component and its children have a rather simple and straightforward way to communicate. Parents pass data as props
to their children, and these raise events (emits
) to capture the attention of the parent. Much like the comparability of parameters and arguments in functions, props
receive simple data by copy, and complex types (objects, arrays, and so on) by reference. We could pass, then, a plain object with member functions from the parent to the child, and have the child run the functions to access the parent’s data. Even though this “works”, it is sort of a dark pattern or anti-pattern, as it hides the relationship and makes it difficult to understand the data flow. The proper way to pass data upward in the component tree is through events (emits
). Having said this, we must point out that child components are “ignorant” of each other, meaning that they do not have a direct...