Last active
April 26, 2019 22:16
-
-
Save PxyUp/75197285d1b87f6eb90f3490b40cf599 to your computer and use it in GitHub Desktop.
CounterComponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bootstrap, Component, rValue, createComponent } from 'revact'; | |
class Counter extends Component { | |
reactive = { | |
counter: rValue(0) | |
} | |
template = { | |
tag: "span", | |
textValue: this.reactive.counter, | |
listeners: { | |
click: () => { | |
this.reactive.counter.value++ | |
} | |
} | |
} | |
} | |
function createCounter() { | |
return createComponent(Counter) | |
} | |
bootstrap('#first', createCounter) | |
bootstrap('#second', () => ({ | |
tag: "div", | |
children: [ | |
{ | |
tag: "textNode", | |
textValue: "Counter:" | |
}, | |
createCounter(), | |
] | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment