Skip to content

3.1.0

Compare
Choose a tag to compare
@JulianFun123 JulianFun123 released this 06 Mar 00:33
· 23 commits to master since this release

Typescript Class-Component

import { html, JDOMComponent } from 'jdomjs' 
import { CustomElement, State } from "jdomjs/decorator.ts";

@CustomElement('example-component')
class ExampleComponent extends JDOMComponent {
    @State()
    private name: Hook<String> = 'John'
  
    @Computed(s => [s.name])
    private greetings() {
        return comp`Hello ${this.name}`
    }
  
    render() {
          return html`
            <input :bind=${this.name}>
            <h1>${this.greetings}</h1>
          `
    }
}

Javascript Class-Component

import { html, JDOMComponent, $r } from 'jdomjs'

class ExampleComponent extends JDOMComponent {
    private name = new Hook('John')
  
    private greetings() {
        return comp`Hello ${this.name}`
    }
  
    render() {
          return html`
            <input :bind=${this.name}>
            <h1>${this.greetings()}</h1>
          `
    }
}

$r('example-component', ExampleComponent)