Skip to content

Commit c7dd17c

Browse files
authored
Update main.jsx
1 parent c74b55f commit c7dd17c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

frameworks/keyed/pota/src/main.jsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ function _random(max) {
6767
function buildData(count) {
6868
const data = new Array(count)
6969
for (let i = 0; i < count; i++) {
70-
const [label, setLabel, updateLabel] = signal(
70+
const label = signal(
7171
`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`,
7272
)
73-
data[i] = {
74-
id: idCounter++,
75-
label,
76-
updateLabel,
77-
}
73+
label.id = idCounter++
74+
data[i] = label
7875
}
7976
return data
8077
}
@@ -86,14 +83,17 @@ const Button = ({ id, text, fn }) => (
8683
id={id}
8784
class="btn btn-primary btn-block"
8885
type="button"
89-
on:click={fn}
86+
on:click={(e)=>{
87+
e.stopPropagation()
88+
fn()
89+
}
9090
/>
9191
</div>
9292
)
9393

9494
const App = () => {
9595
const [data, setData, updateData] = signal([]),
96-
[selected, setSelected] = signal(null),
96+
[selected, setSelected] = signal(),
9797
run = () => {
9898
setData(buildData(1000))
9999
},
@@ -107,7 +107,7 @@ const App = () => {
107107
const d = data()
108108
const len = d.length
109109
for (let i = 0; i < len; i += 10)
110-
d[i].updateLabel(l => l + ' !!!')
110+
d[i].update(l => l + ' !!!')
111111
},
112112
swapRows = () => {
113113
const d = [...data()]
@@ -176,6 +176,8 @@ const App = () => {
176176
<table
177177
class="table table-hover table-striped test-data"
178178
on:click={e => {
179+
e.stopPropagation()
180+
179181
const element = e.target
180182
const { selectRow, removeRow } = element
181183

@@ -189,7 +191,7 @@ const App = () => {
189191
<tbody>
190192
<For each={data}>
191193
{row => {
192-
const { id, label } = row
194+
const { id, read } = row
193195

194196
return (
195197
<tr class:danger={isSelected(id)}>
@@ -199,7 +201,7 @@ const App = () => {
199201
/>
200202
<td class="col-md-4">
201203
<a
202-
textContent={label}
204+
textContent={read}
203205
prop:selectRow={id}
204206
/>
205207
</td>

0 commit comments

Comments
 (0)