summaryrefslogtreecommitdiff
path: root/examples/with-mdx/src/components/Counter.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/with-mdx/src/components/Counter.jsx')
-rw-r--r--examples/with-mdx/src/components/Counter.jsx18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/with-mdx/src/components/Counter.jsx b/examples/with-mdx/src/components/Counter.jsx
new file mode 100644
index 000000000..801eefe73
--- /dev/null
+++ b/examples/with-mdx/src/components/Counter.jsx
@@ -0,0 +1,18 @@
+import { useState } from 'preact/hooks';
+
+export default function Counter({ children }) {
+ const [count, setCount] = useState(0);
+ const add = () => setCount((i) => i + 1);
+ const subtract = () => setCount((i) => i - 1);
+
+ return (
+ <>
+ <div class="counter">
+ <button onClick={subtract}>-</button>
+ <pre>{count}</pre>
+ <button onClick={add}>+</button>
+ </div>
+ <div class="counter-message">{children}</div>
+ </>
+ );
+}