This allows users to control the `preact` version independently of fresh itself.
24 lines
545 B
TypeScript
24 lines
545 B
TypeScript
/** @jsx h */
|
|
import { h } from "preact";
|
|
import { useState } from "preact/hooks";
|
|
import { IS_BROWSER } from "$fresh/runtime.ts";
|
|
|
|
interface CounterProps {
|
|
start: number;
|
|
}
|
|
|
|
export default function Counter(props: CounterProps) {
|
|
const [count, setCount] = useState(props.start);
|
|
return (
|
|
<div>
|
|
<p>{count}</p>
|
|
<button onClick={() => setCount(count - 1)} disabled={!IS_BROWSER}>
|
|
-1
|
|
</button>
|
|
<button onClick={() => setCount(count + 1)} disabled={!IS_BROWSER}>
|
|
+1
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|