-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathNestedProxy.njs
More file actions
57 lines (45 loc) · 1.38 KB
/
NestedProxy.njs
File metadata and controls
57 lines (45 loc) · 1.38 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
53
54
55
56
57
import Nullstack from 'nullstack'
class ShouldNotProxy {
something = false
setSomething(value) {
this.something = value
}
}
class NestedProxy extends Nullstack {
array = [{ object: { object: true } }]
object = {
array: [true],
}
prepare(context) {
context.array = [{ object: { object: true } }]
context.object = {
array: [true],
}
}
hydrate(context) {
this.shouldNotProxy = new ShouldNotProxy()
this.shouldNotProxy.setSomething(true)
context.shouldNotProxy = new ShouldNotProxy()
context.shouldNotProxy.setSomething(true)
}
render({ array, object, shouldNotProxy }) {
if (!this.hydrated) return false
return (
<div
data-array={!!this.array._isProxy}
data-array-zero={!!this.array[0]._isProxy}
data-array-zero-object={!!this.array[0].object._isProxy}
data-object={!!this.object._isProxy}
data-object-array={!!this.object.array._isProxy}
data-should-not-proxy={!this.shouldNotProxy._isProxy}
data-context-array={!!array._isProxy}
data-context-array-zero={!!array[0]._isProxy}
data-context-array-zero-object={!!array[0].object._isProxy}
data-context-object={!!object._isProxy}
data-context-object-array={!!object.array._isProxy}
data-context-should-not-proxy={!shouldNotProxy._isProxy}
/>
)
}
}
export default NestedProxy