-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathErrorOnChildNode.njs
More file actions
78 lines (65 loc) · 1.38 KB
/
ErrorOnChildNode.njs
File metadata and controls
78 lines (65 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import Nullstack from 'nullstack'
class ObjectId {
constructor(id) {
this.id = id
}
toJSON() {
return this.id
}
}
class ErrorOnChildNode extends Nullstack {
value = 'initial Value'
records = [{ _id: new ObjectId('a') }]
testClick() {
this.value = 'Changed Value'
}
renderSerializationError() {
const records = this.records.filter((r) => r._id === 'a')
if (!records.length) return false
return (
<div>
{records.map((record) => (
<div>{record._id}</div>
))}
</div>
)
}
renderDOMError() {
return (
<table>
<thead>
<th>No.</th>
<th>Fisrt Name</th>
<th>Last Name</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Jeanette</td>
<td>Penddreth</td>
</tr>
<tr>
<td>2</td>
<td>Giavani</td>
<td>Frediani</td>
</tr>
</tbody>
</table>
)
}
render({ params }) {
return (
<>
<h2> Table Error </h2>
{params.serialization && <SerializationError />}
{params.dom && <DOMError />}
<div data-value={this.value}>{this.value}</div>
<button data-dom-error onclick={this.testClick}>
{' '}
Change Value{' '}
</button>
</>
)
}
}
export default ErrorOnChildNode