Files
sweet/tests/fixture/islands/Counter.tsx
T
Luca Casonato cbbf616a74 chore: version preact explicitly in import map (#258)
This allows users to control the `preact` version independently of fresh
itself.
2022-06-20 12:37:24 +02:00

26 lines
524 B
TypeScript

/** @jsx h */
import { h } from "preact";
import { useState } from "preact/hooks";
import { IS_BROWSER } from "$fresh/runtime.ts";
interface CounterProps {
start: number;
id: string;
}
export default function Counter(props: CounterProps) {
const [count, setCount] = useState(props.start);
return (
<div id={props.id}>
<p>{count}</p>
<button
id={`b-${props.id}`}
onClick={() => setCount(count + 1)}
disabled={!IS_BROWSER}
>
+1
</button>
</div>
);
}