deno.land / x / fresh@1.1.1 / examples / counter / islands / Counter.tsx

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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> );}
fresh

Version Info

Tagged at
2 years ago