Buckets:
| "use client"; | |
| import { useActionState } from "react"; | |
| import { useFormStatus } from "react-dom"; | |
| import { createTodo } from "@/app/actions"; | |
| const initialState = { | |
| message: "", | |
| }; | |
| function SubmitButton() { | |
| const { pending } = useFormStatus(); | |
| return ( | |
| <button type="submit" aria-disabled={pending}> | |
| Add | |
| </button> | |
| ); | |
| } | |
| export function AddForm() { | |
| // useActionState is available with React 19 (Next.js App Router) | |
| const [state, formAction] = useActionState(createTodo, initialState); | |
| return ( | |
| <form action={formAction}> | |
| <label htmlFor="todo">Enter Task</label> | |
| <input type="text" id="todo" name="todo" required /> | |
| <SubmitButton /> | |
| <p aria-live="polite" className="sr-only" role="status"> | |
| {state?.message} | |
| </p> | |
| </form> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 803 Bytes
- Xet hash:
- 9709694ede78660b61514d0987f8933183663cd5bd4942537b3f0a3a056ef76e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.