| 1 | 'use client'; |
| 2 | |
| 3 | import * as React from 'react'; |
| 4 | import {useFormStatus} from 'react-dom'; |
| 5 | import ErrorBoundary from './ErrorBoundary.js'; |
| 6 | |
| 7 | function Status() { |
| 8 | const {pending} = useFormStatus(); |
| 9 | return pending ? 'Saving...' : null; |
| 10 | } |
| 11 | |
| 12 | export default function Form({action, children}) { |
| 13 | const [isPending, setIsPending] = React.useState(false); |
| 14 | |
| 15 | return ( |
| 16 | <ErrorBoundary> |
| 17 | <form action={action}> |
| 18 | <label> |
| 19 | Name: <input name="name" /> |
| 20 | </label> |
| 21 | <label> |
| 22 | File: <input type="file" name="file" /> |
| 23 | </label> |
| 24 | <button>Say Hi</button> |
| 25 | <Status /> |
| 26 | </form> |
| 27 | </ErrorBoundary> |
| 28 | ); |
| 29 | } |