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