23 lines
515 B
TypeScript
23 lines
515 B
TypeScript
"use client";
|
|
|
|
import { refreshWeatherData } from "@/app/actions";
|
|
import { useTransition, JSX } from "react";
|
|
|
|
export default function RefreshButton(): JSX.Element {
|
|
const [isPending, startTransition] = useTransition();
|
|
|
|
return (
|
|
<button
|
|
className="btn btn-primary"
|
|
disabled={isPending}
|
|
onClick={() => {
|
|
startTransition(async () => {
|
|
await refreshWeatherData();
|
|
});
|
|
}}
|
|
>
|
|
{isPending ? "Refreshing..." : "Refresh Weather Now"}
|
|
</button>
|
|
);
|
|
}
|