Skip to content

Commit 5a9e230

Browse files
committed
Clean up code example for Handling multiple submission types
1 parent 947c926 commit 5a9e230

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • src/content/reference/react-dom/components

src/content/reference/react-dom/components/form.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ export default function ArticleForm() {
472472
const content = payload.data.get('content');
473473
switch (payload.type) {
474474
case 'save':
475-
476475
alert(`Your draft of '${content}' was saved!`);
477476
// Keep the submitted content as the current draft
478477
return payload.data;
@@ -481,23 +480,22 @@ export default function ArticleForm() {
481480
// reset the form
482481
return new FormData();
483482
}
484-
});
483+
}, new FormData());
485484

486485
function publish(formData) {
487486
dispatchFormState({
488487
type: 'publish',
489488
data: formData
490-
})
489+
});
491490
}
492491

493492
function save(formData) {
494493
dispatchFormState({
495494
type: 'save',
496495
data: formData
497-
})
496+
});
498497
}
499498

500-
// const savedContent = draft.get('content') || '';
501499
return (
502500
<form action={publish}>
503501
<textarea

0 commit comments

Comments
 (0)