-
Notifications
You must be signed in to change notification settings - Fork 25
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
Replicate useActionState API? #29
Comments
added docs for useFormState hook to address #29
Hi @karlhorky , no problem and thank you! I just added to the docs an example of using this library with To me, Lmk if you would like something more than what is in these new docs. Hopefully they help out. For now I will close this issue. |
Ah, thanks for the docs! But that's not really what I mean. (also, those docs should probably be updated, as What I mean is that const
- { isPending, execute, data }
+ [state, action, isPending]
= useServerAction(incrementNumberAction); This would make it easier to migrate to zsa and make it more relevant longer term. |
Sorry it took a minute to get to this, but just opened a PR that I think now addresses your suggestion #64 . |
Nice, thanks! Took a quick look, and one small point of feedback: as a user, I would not be 100% sure why I would have to pass import { useActionState } from "react"
import { createActionStateHookFrom } from "zsa-react"
const useAction = createActionStateHookFrom(useActionState)
export default function UseActionStateExample() {
const [{ data, error }, submitAction, isPending] =
useAction(produceNewMessage) I would expect something more like this: import { useAction } from "zsa-react"
export default function UseActionStateExample() {
const [{ data, error }, submitAction, isPending] =
useAction(produceNewMessage) |
It's a good point. Debating whether or not to add the canary version of react as a dep to |
The v19 beta and RC versions already have Maybe a (relaxed) peer dependency? eg. something like
|
Hi, after much thought I have decided to go with the latest proposal mentioned in #64. This is different from a new hook -- rather just makes using |
Oh interesting, that seems like a more minimal layer on top of |
Hi, thanks for this library, looks cool!
For
useServerAction
, would you consider replicating the API of React'suseActionState
hook to make it easier to migrate / understand?The text was updated successfully, but these errors were encountered: