mirror of
https://github.com/D4M13N-D3V/neroshitron.git
synced 2025-06-16 13:19:17 +00:00
21 lines
495 B
TypeScript
21 lines
495 B
TypeScript
"use client";
|
|
|
|
import { useFormStatus } from "react-dom";
|
|
import { type ComponentProps } from "react";
|
|
|
|
type Props = ComponentProps<"button"> & {
|
|
pendingText?: string;
|
|
};
|
|
|
|
export function SubmitButton({ children, pendingText, ...props }: Props) {
|
|
const { pending, action } = useFormStatus();
|
|
|
|
const isPending = pending && action === props.formAction;
|
|
|
|
return (
|
|
<button {...props} type="submit" aria-disabled={pending}>
|
|
{isPending ? pendingText : children}
|
|
</button>
|
|
);
|
|
}
|