-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathPersistentComponent.njs
More file actions
52 lines (42 loc) · 1.04 KB
/
PersistentComponent.njs
File metadata and controls
52 lines (42 loc) · 1.04 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Nullstack from 'nullstack'
class PersistentComponent extends Nullstack {
count = 0
launchCount = 0
prepare() {
this.count = -1
}
async initiate() {
this.count = -1
}
launch() {
if (this.initiated) {
this.launchCount++
}
}
async hydrate() {
this.count++
}
terminate() {
this.count++
}
render({ instances }) {
const aCount = instances['PersistentComponent/0-0-33/persistent-component/a']?.count
const aTerminated = instances['PersistentComponent/0-0-33/persistent-component/a']?.terminated
return (
<div
data-count={this.count}
data-key={this.key}
data-a-count={aCount}
data-launch-count={this.launchCount}
data-persistent={this.persistent}
data-prerendered={this.prerendered}
data-a-terminated={aTerminated}
data-hydrated={this.hydrated}
>
<a href="/persistent-component/a"> a </a>
<a href="/persistent-component/b"> b </a>
</div>
)
}
}
export default PersistentComponent