t3-code-android-nightly/.repos/alchemy-effect/examples/aws-website-vinext/app/components/Counter.tsx
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

31 lines
859 B
TypeScript

"use client";
import { useState } from "react";
export function Counter() {
const [count, setCount] = useState(0);
const [greeting, setGreeting] = useState("");
async function loadGreeting() {
try {
const response = await fetch("/api/hello?name=browser");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const body = (await response.json()) as { greeting: string };
setGreeting(body.greeting);
} catch {
setGreeting("Could not load the greeting. Try again.");
}
}
return (
<section className="mt-4 flex flex-col gap-2">
<button type="button" onClick={() => setCount((value) => value + 1)}>
count: {count}
</button>
<button type="button" onClick={loadGreeting}>
Load greeting
</button>
<p role="status">{greeting}</p>
</section>
);
}