silverwolf-x's picture
download
raw
851 Bytes
"use client";
import { useActionState } from "react";
import { useFormStatus } from "react-dom";
import { deleteTodo } from "@/app/actions";
const initialState = {
message: "",
};
function DeleteButton() {
const { pending } = useFormStatus();
return (
<button type="submit" aria-disabled={pending}>
Delete
</button>
);
}
export function DeleteForm({ id, todo }: { id: number; todo: string }) {
// useActionState is available with React 19 (Next.js App Router)
const [state, formAction] = useActionState(deleteTodo, initialState);
return (
<form action={formAction}>
<input type="hidden" name="id" value={id} />
<input type="hidden" name="todo" value={todo} />
<DeleteButton />
<p aria-live="polite" className="sr-only" role="status">
{state?.message}
</p>
</form>
);
}

Xet Storage Details

Size:
851 Bytes
·
Xet hash:
105dd9d7cca5aefd40d4be5f94e6e1745cc588e1508d7b4cda046d6f5b8c9918

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.