score:12

Accepted answer

so it appears that all of the components get the child context of where they are created. in this case <baz /> is created as a part of foo, so it gets the child context from foo, which is why it's undefined.

couple of options.

1) set the child context on foo.
2) recreate the <baz> child in bar. you can do this with clonewithprops.

render: function() {
   console.log(this);
   return react.addons.clonewithprops(this.props.children)
}

updated fiddle: https://jsfiddle.net/crob611/3h7pxnkx/2/

issue on react project discussing it: https://github.com/facebook/react/issues/3392


Related Query

More Query from same tag