Files
sweet/tests/fixtures_islands/Counter.tsx
T
Tim Reichen 0a634bd2d2 chore: fix lint errors (#2833)
This PR fixes current lint errors thrown by `deno lint`.
2025-03-05 12:31:25 +01:00

35 lines
733 B
TypeScript

import { type Signal, useSignal } from "@preact/signals";
import { useEffect } from "preact/hooks";
export interface CounterProps {
id?: string;
count: Signal<number>;
}
export function Counter(props: CounterProps) {
const active = useSignal(false);
useEffect(() => {
active.value = true;
}, []);
return (
<div id={props.id} class={active.value ? "ready" : ""}>
<button
type="button"
class="decrement"
onClick={() => props.count.value -= 1}
>
-1
</button>
<p class="output">{props.count}</p>
<button
type="button"
class="increment"
onClick={() => props.count.value += 1}
>
+1
</button>
</div>
);
}