Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between bind vs closure in Server Actions #827

Open
AmitJoki opened this issue Aug 9, 2024 · 0 comments
Open

Difference between bind vs closure in Server Actions #827

AmitJoki opened this issue Aug 9, 2024 · 0 comments

Comments

@AmitJoki
Copy link

AmitJoki commented Aug 9, 2024

In this section

There is a statement

Instead, you can pass id to the Server Action using JS bind. This will ensure that any values passed to the Server Action are encoded.

const updateInvoiceWithId = updateInvoice.bind(null, invoice.id);

We can do the following without bind and it works alright.

<form action={(formData) => updateInvoice(invoice.id, formData)}>

Is there a difference between the two?

@AmitJoki AmitJoki changed the title In pass the id to the server action, what has bind got to do with encoding values? Difference between bind vs closure in Server Actions Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant