Class: Component

Reactive.Component()

Base class for creating reactive components with lifecycle methods. Provides automatic state management, DOM binding, and cleanup. Lifecycle methods (override in subclass): - state(): Returns initial state object (converted to signals) - init(): Called after state initialization, before rendering (optional) - template(): Returns html tagged template for the component (required) - styles(): Returns css class name for styling (optional) - mount(): Called after component is mounted to DOM (optional) - onCleanup(): Called during cleanup (optional)

Constructor

new Component()

Source:
Example
class Counter extends Reactive.Component {
  state() {
    return { count: 0 };
  }
  template() {
    return html`<button data-on-click="increment">${this.count}</button>`;
  }
  increment() {
    this.count.set(this.count.get() + 1);
  }
}