next.js
fe90b04f - (docs) Document Server Actions `.bind` method (#56164)

Commit
2 years ago
(docs) Document Server Actions `.bind` method (#56164) This will be the recommended way of passing extra arguments to a Server Action. A couple of reasons behind: - This is better than putting a hidden `<input hidden value={userId}/>` because that will appear in the SSR'd HTML as full text and cannot be encoded. With `.bind`, we can handle that in the future. - This is better than event callbacks `onSubmit={(e) => { await updateUser(userId, e.target.formData) }}` as this supports progressive enhancement. - This is better than re-creating a new action `action={async (formData) => { "use server"; return updateUser(userId, formData) }}` as inlined `"use server"` only works in Server Components.
Author
Parents
Loading