summaryrefslogtreecommitdiff
path: root/examples/framework-preact/src/components/Counter.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/framework-preact/src/components/Counter.tsx')
-rw-r--r--examples/framework-preact/src/components/Counter.tsx8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/framework-preact/src/components/Counter.tsx b/examples/framework-preact/src/components/Counter.tsx
index 5d702fb42..61a9f9d5a 100644
--- a/examples/framework-preact/src/components/Counter.tsx
+++ b/examples/framework-preact/src/components/Counter.tsx
@@ -1,9 +1,11 @@
import { h, Fragment } from 'preact';
+import { useState } from 'preact/hooks';
import './Counter.css';
-export default function Counter({ children, count }) {
- const add = () => count.value++;
- const subtract = () => count.value--;
+export default function Counter({ children }) {
+ const [count, setCount] = useState(0);
+ const add = () => setCount((i) => i + 1);
+ const subtract = () => setCount((i) => i - 1);
return (
<>