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

[FEATURE] [v7] Support stateful actions using React useActionState hook #91

Closed
TheEdoRan opened this issue Mar 28, 2024 · 1 comment · Fixed by #110
Closed

[FEATURE] [v7] Support stateful actions using React useActionState hook #91

TheEdoRan opened this issue Mar 28, 2024 · 1 comment · Fixed by #110
Labels
enhancement New feature or request
Milestone

Comments

@TheEdoRan
Copy link
Owner

TheEdoRan commented Mar 28, 2024

useActionState will replace the previous useFormState hook. When the new hook will be available in Next.js, we can start working on the Form Actions support.

And since that useActionState will work both with and without form elements, it means that probably there's no need to introduce a new hook in next-safe-action. My current idea is to update useAction and useOptimisticAction hooks to use useActionState under the hood. Action signature will change if this will be the case, since the action requires previousState to be the argument placed between optional bind params and form data, in the function called by the client.

UPDATE: implemented stateful action support in the library via stateAction instance method and useStateAction hook. Updated useOptimisticAction API too.

When this PR gets merged, updated documentation will be available here:


Please note that React's useActionState hook is available in Next.js since 14.3.0-canary version, so once the PR gets merged you are required to use a canary release. When the support for it will land in a Next.js stable version, the next branch of next-safe-action will be merged into main, and version 7 will be released with all the new features.

@TheEdoRan TheEdoRan added this to the v7 milestone Mar 28, 2024
@TheEdoRan TheEdoRan added the enhancement New feature or request label Mar 28, 2024
@TheEdoRan TheEdoRan changed the title FEATURE [v7] Support a variable number of arguments in actions FEATURE [v7] Support Form Actions Apr 6, 2024
@TheEdoRan
Copy link
Owner Author

@TheEdoRan TheEdoRan changed the title FEATURE [v7] Support Form Actions FEATURE [v7] Support Form Actions via React useActionState hook Apr 25, 2024
@TheEdoRan TheEdoRan changed the title FEATURE [v7] Support Form Actions via React useActionState hook [FEATURE] [v7] Support Form Actions via React useActionState hook Apr 25, 2024
@TheEdoRan TheEdoRan changed the title [FEATURE] [v7] Support Form Actions via React useActionState hook [FEATURE] [v7] Support stateful actions via React useActionState hook Apr 27, 2024
@TheEdoRan TheEdoRan changed the title [FEATURE] [v7] Support stateful actions via React useActionState hook [FEATURE] [v7] Support stateful actions using React useActionState hook Apr 28, 2024
@TheEdoRan TheEdoRan pinned this issue May 7, 2024
@TheEdoRan TheEdoRan unpinned this issue Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant