I'm creating a JSX component with StencilJS and my component isn't re-rendering based on its state change. I have no idea why:
import { Component, Prop, State } from '@stencil/core'
@Component({
tag: "button-popover-group",
})
export class ButtonPopoverContainer{
@State() showPopover:boolean = false;
@Prop() popoverContent:JSX.Element;
toggleShowPopover() {
this.showPopover = !this.showPopover;
console.log(this.showPopover);
}
render() {
return (
<div class="rba-something">
<my-button onClick={this.toggleShowPopover}/>
{this.showPopover ?
<my-popover>
{this.popoverContent}
</my-popover> :
null
}
</div>
)
}
}
My console log statement verifies that the state is being changed, but for some reason my popover box is never visible
Ok, the answer was to change the toggle function to a fat arrow function, as the binding to 'this' was getting lost in the JSX