[FEATURE] [v7] Support stateful actions using React useActionState
hook
#91
Labels
enhancement
New feature or request
Milestone
useActionState
will replace the previoususeFormState
hook. When the new hook will be available in Next.js, we can start working on the Form Actions support.And since thatuseActionState
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 updateuseAction
anduseOptimisticAction
hooks to useuseActionState
under the hood. Action signature will change if this will be the case, since the action requirespreviousState
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 anduseStateAction
hook. UpdateduseOptimisticAction
API too.useAction
uses React'suseTransition
hook under the hood.useOptimisticAction
uses React'suseOptimistic
hook under the hood.useStateAction
uses React'suseActionState
hook under the hood.When this PR gets merged, updated documentation will be available here:
stateAction
method anduseStateAction
hook #110Please 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, thenext
branch of next-safe-action will be merged intomain
, and version 7 will be released with all the new features.The text was updated successfully, but these errors were encountered: