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
+4 -4
View File
@@ -1,15 +1,15 @@
import { useState } from "preact/hooks";
import { useSignal } from "@preact/signals";
export default function RootFragment() {
const [shown, setShown] = useState(false);
const shown = useSignal(false);
return (
<>
Hello
<div onClick={() => setShown(true)} id="root-fragment-click-me">
<div onClick={() => shown.value = true} id="root-fragment-click-me">
World
</div>
{shown && <div>I'm rendered now</div>}
{shown.value && <div>I'm rendered now</div>}
</>
);
}