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

(docs) Fixes Server Actions example #53920

Merged
merged 2 commits into from Aug 11, 2023
Merged

(docs) Fixes Server Actions example #53920

merged 2 commits into from Aug 11, 2023

Conversation

shuding
Copy link
Member

@shuding shuding commented Aug 11, 2023

Closes #53910.

@schimi-dev
Copy link

I am not sure if the original issue was actually a bug in the code sample.

From how I understand this, the function named action is actually a Client Action that internally calls the Server Action named updateItem. Then, the form receives that Client Action (not the Server Action directly) as action prop.

Using Server Actions composed within Client Actions that way seems to work quite well from what I tested. Maybe it would be good to state in the docs whether it is an allowed pattern to wrap Server Action in Client Actions and then pass that Client Action as action prop to a form.

Technically, this patterns seems to work perfectly fine at the moment, and I think there might be a lot of use cases for it (e.g. Client-side Form validation or preprocessing of data, so that you do not have to pass FormData to the Server Action but some already preprocessed custom object).

@kodiakhq kodiakhq bot merged commit 10cb740 into canary Aug 11, 2023
52 checks passed
@kodiakhq kodiakhq bot deleted the shu/b0d5 branch August 11, 2023 18:25
ijjk pushed a commit that referenced this pull request Aug 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Bug in the code sample for server actions in client component.
4 participants