Skip to content

Commit

Permalink
Update 02-server-actions-and-mutations.mdx - FormData is itself itera…
Browse files Browse the repository at this point in the history
…ble (#62541)

FormData objects are iterable, so we can get entries directly without
the need for calling .entries().

Co-authored-by: Sam Ko <sam@vercel.com>
  • Loading branch information
michaltarasiuk and samcx authored Mar 13, 2024
1 parent 08d7a7e commit de5ea0f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default function Page() {
> **Good to know:**
>
> - Example: [Form with Loading & Error States](https://github.com/vercel/next.js/tree/canary/examples/next-forms)
> - When working with forms that have many fields, you may want to consider using the [`entries()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries) method with JavaScript's [`Object.fromEntries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries). For example: `const rawFormData = Object.fromEntries(formData.entries())`. One thing to note is that the `formData` will include additional `$ACTION_`properties.
> - When working with forms that have many fields, you may want to consider using the [`entries()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries) method with JavaScript's [`Object.fromEntries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries). For example: `const rawFormData = Object.fromEntries(formData)`. One thing to note is that the `formData` will include additional `$ACTION_` properties.
> - See [React `<form>` documentation](https://react.dev/reference/react-dom/components/form#handle-form-submission-with-a-server-action) to learn more.
#### Passing Additional Arguments
Expand Down

0 comments on commit de5ea0f

Please sign in to comment.