refactor: replace useState() with useSignal() (#1234)

This commit is contained in:
Asher Gomez
2023-06-02 06:43:01 +10:00
committed by GitHub
parent 7b35cb07d4
commit 8fa4141e06
15 changed files with 120 additions and 112 deletions
+3 -4
View File
@@ -14,15 +14,14 @@ island. The file must have a default export that is a regular Preact component.
```tsx
// islands/MyIsland.tsx
import { useState } from "preact/hooks";
import type { Signal } from "@preact/signals";
export default function MyIsland() {
const [count, setCount] = useState(0);
const count = useSignal(0);
return (
<div>
Counter is at {count}.{" "}
<button onClick={() => setCount(count + 1)}>+</button>
Counter is at {count}. <button onClick={() => count.value += 1}>+</button>
</div>
);
}