If I nest components C1,…Cn inside of a parent component P, could I access the child components from the parent? I think the answer is no, unless I explicitly maintain a list of references in code.
A toy example:
def __init__(self):
self.p = MyParentComponent()
self.add_component(self.p)
self.p.add_component(c1)
...
self.p.add_component(cn)
def get_children(self):
# I cannot get self.p's children because I did not maintain an explicit reference
pass
From a design perspective, why do we not have a way to get the children of a component at run time, similar to how it’s possible to get HTML DOM element’s children?
const collection = document.body.children;