wcb/examples/demo/Toggle.js
Ayo 9268676797 fix: static props makes state shared across class instances
- uses structuredClone on static props
- closes #28
2023-12-16 09:03:01 +01:00

16 lines
349 B
JavaScript

import { WebComponent, html } from "../../src/index.js";
class Toggle extends WebComponent {
static props = {
toggle: false,
};
get template() {
return html`
<button onClick=${() => (this.props.toggle = !this.props.toggle)}>
${this.props.toggle}
</button>
`;
}
}
customElements.define("my-toggle", Toggle);