diff options
Diffstat (limited to 'packages/astro/test/fixtures/astro-jsx/src/components/PreactCounter.tsx')
-rw-r--r-- | packages/astro/test/fixtures/astro-jsx/src/components/PreactCounter.tsx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/astro/test/fixtures/astro-jsx/src/components/PreactCounter.tsx b/packages/astro/test/fixtures/astro-jsx/src/components/PreactCounter.tsx new file mode 100644 index 000000000..81eba8652 --- /dev/null +++ b/packages/astro/test/fixtures/astro-jsx/src/components/PreactCounter.tsx @@ -0,0 +1,20 @@ +import { Fragment, h } from 'preact'; +import { useState } from 'preact/hooks'; + +/** a counter written in Preact */ +export default function PreactCounter() { + const [count, setCount] = useState(0); + const add = () => setCount((i) => i + 1); + const subtract = () => setCount((i) => i - 1); + + return ( + <div id="preact"> + <div className="counter"> + <button onClick={subtract}>-</button> + <pre>{count}</pre> + <button onClick={add}>+</button> + </div> + <div className="children">Preact</div> + </div> + ); +} |