File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed
Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change 11'use client' ;
22
33import * as React from 'react' ;
4+ import ErrorBoundary from './ErrorBoundary.js' ;
45
56export default function Form ( { action, children} ) {
67 const [ isPending , setIsPending ] = React . useState ( false ) ;
78
89 return (
9- < form
10- action = { async formData => {
11- setIsPending ( true ) ;
12- try {
13- const result = await action ( formData ) ;
14- alert ( result ) ;
15- } catch ( error ) {
16- console . error ( error ) ;
17- } finally {
18- setIsPending ( false ) ;
19- }
20- } } >
21- < input name = "name" / >
22- < button > Say Hi </ button >
23- </ form >
10+ < ErrorBoundary >
11+ < form
12+ action = { async formData => {
13+ setIsPending ( true ) ;
14+ try {
15+ const result = await action ( formData ) ;
16+ alert ( result ) ;
17+ } finally {
18+ setIsPending ( false ) ;
19+ }
20+ } } >
21+ < input name = "name" / >
22+ < button > Say Hi </ button >
23+ </ form >
24+ </ ErrorBoundary >
2425 ) ;
2526}
You can’t perform that action at this time.
0 commit comments