Skip to content

Commit a9a1046

Browse files
committed
update examples for auto detection
1 parent c6c058e commit a9a1046

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

playground/Container.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @island
2-
31
import { signal } from '@preact/signals'
42
import Counter from './Counter'
53
import TextIsland from './TextIsland'
@@ -8,10 +6,17 @@ import CounterTS from './CounterTS'
86
const count = signal(0)
97

108
export default function Container({ children }) {
9+
function onInc() {
10+
count.value += 1
11+
}
1112
return (
1213
<>
13-
<Counter value={count} inc={() => (count.value += 1)} />
14-
<CounterTS value={count} inc={() => (count.value += 1)} />
14+
<div>
15+
<p>Shared State:</p>
16+
<Counter value={'+'} inc={onInc} />
17+
<span>{count}</span>
18+
<CounterTS value={'-'} inc={() => (count.value -= 1)} />
19+
</div>
1520
<TextIsland />
1621
</>
1722
)

playground/CounterTS.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ export default function CounterTS({ value, inc }: Props) {
1414
return (
1515
<>
1616
<button onClick={inc}>{value}</button>
17-
<button onClick={() => (internalCount.value += 1)}>
18-
internal:{internalCount}
19-
</button>
17+
<div>
18+
internal to CounterTS:
19+
<button onClick={() => (internalCount.value += 1)}>
20+
{internalCount}
21+
</button>
22+
</div>
2023
</>
2124
)
2225
}

playground/TextIsland.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @island
21
import { useState } from 'preact/hooks'
32

43
export default function TextIsland() {

0 commit comments

Comments
 (0)