Versions
@stencil/core - 0.12.2
@stencil/state-tunnel - 0.0.7
First, thanks for this work! It seems like it will be useful for us. Hoping that we're just making a stupid usage error, but we're not sure if/what we're doing wrong. Wanted to open it up here in case there was something else going on.
When we attempt to render a Consumer component, we are getting the following error:
TypeError: Cannot destructure property `children` of 'undefined' or 'null'.
at Consumer (chunk-97f9c476.js:53)
at h (our-project.core.js:553)
at OurComponent.render (our-component.js:6022)
at render (our-project.core.js:630)
at renderUpdate (our-project.core.js:752)
at update (our-project.core.js:746)
at push (our-project.core.js:707)
at hostElm.s-rc.forEach.cb (our-project.core.js:662)
at Array.forEach (<anonymous>)
at render (our-project.core.js:662) 8 "OUR-COMPONENT"
Digging through the code listed in the stack trace a bit, it looks like this might be due to the fact that the generated code calls h()
without anything specified in the vnodeData
argument. This results in Consumer attempting to destructure null.
The generated code looks like this (notice the 2nd argument is null).
return (h(Tunnel.Consumer, null, ({ error, success }) => ...
This is the section where the error occurs in h()
:
if ('function' === typeof nodeName)
// nodeName is a functional component
return nodeName(vnodeData, children || [], utils); /* vnodeData is undefined here. so this becomes Consumer(null)
The render method for OurComponent:
return (
<Tunnel.Consumer>
{
({ error, success }) => (
<label class={ourComponentClasses}>
<input
class="our-component__control"
checked={this.checked}
disabled={this.disabled}
name={this.name}
type="radio"
value={this.value}
/>
<span
class={`
${ourComopnentIndicatorClasses}
${error && 'our-component__indicator--error'}
${success && 'our-component__indicator--success'}
`}
/>
<span class="our-component__label">{this.label}</span>
</label>
)}
</Tunnel.Consumer>
);
Thanks again - any ideas are appreciated.