revite/src/lib/PaintCounter.tsx

13 lines
329 B
TypeScript
Raw Normal View History

2021-06-19 07:34:53 -04:00
import { useState } from "preact/hooks";
const counts: { [key: string]: number } = {};
export default function PaintCounter() {
const [uniqueId] = useState('' + Math.random());
const count = counts[uniqueId] ?? 0;
counts[uniqueId] = count + 1;
return (
<span>Painted {count + 1} time(s).</span>
)
}