peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

this.parentComponent() and this.childComponents() are not working #102

Closed kokjinsam closed 9 years ago

kokjinsam commented 9 years ago

I'm not sure I'm doing something wrong but here's my use case:

Let's say I have two components namely componentA and componentB:

componentA = BlazeComponent.extendComponent({
    onRendered: function() {
      console.log(this.componentName()+' child component is '+this.childComponents());
});

and

componentB = BlazeComponent.extendComponent({
    onRendered: function() {
      console.log(this.componentName()+' parent component is '+this.parentComponent());
});

In a HTML file, I have something like this:

<body>
{{#componentA}}
    {{>componentB}}
    {{>componentB}}
{{/componentA}}
</body>

Both this.parentComponent() and this.childComponents() return null. In this case, am I doing something wrong?

mitar commented 9 years ago

I think this is duplicate of #50. The current design is that block components are not in a component tree, but siblings. Use dumpAllComponents to see the component tree to better understand what is happening.

I agree this is unexpected behavior and should probably be fixed.

kokjinsam commented 9 years ago

Ahh. Thanks for clearing it up!