forked from cevek/fast-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
38 lines (30 loc) · 869 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {render, updater, createElement, Component} from './ts/index';
class App extends Component {
counter = 0;
click() {
this.counter++;
this.forceUpdate();
}
render() {
return createElement('div', {title: this.counter}, 'Hello',
createElement('button', {onClick: ()=>this.click()}, 'SuperClick'),
this.counter,
this.counter % 2 ?
createElement(Wow)
: [1,2,3]
);
}
}
class Wow extends Component {
counter = 0;
click() {
this.counter++;
this.forceUpdate();
}
render() {
return createElement('div', {id: this.counter},
createElement('button', {onClick: ()=>this.click()}, 'Click'),
'Wow', [1, 2, 3], [4, 5, 6], this.counter);
}
}
render(createElement(App), document.body);