Can't get useFormStatus working with Server Action
Answered
Gray-tailed Tattler posted this in #help-forum
Gray-tailed TattlerOP
useFormState seems to be working as expected but i'm not seeing any change to my deconstructed pending flag.
Form -> https://gist.github.com/james0r/4d44ee352128b91a880808a19fb235f9
Action -> https://gist.github.com/james0r/0099e2da6b756d70062a8d4c50257738
Form -> https://gist.github.com/james0r/4d44ee352128b91a880808a19fb235f9
Action -> https://gist.github.com/james0r/0099e2da6b756d70062a8d4c50257738
Answered by Turkish Van
useFormStatus returns the status for a specific <form>, so it must be defined as a child of the <form> element.https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#pending-states
4 Replies
@Gray-tailed Tattler useFormState seems to be working as expected but i'm not seeing any change to my deconstructed pending flag.
Form -> https://gist.github.com/james0r/4d44ee352128b91a880808a19fb235f9
Action -> https://gist.github.com/james0r/0099e2da6b756d70062a8d4c50257738
Turkish Van
useFormStatus returns the status for a specific <form>, so it must be defined as a child of the <form> element.https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#pending-states
Answer
FYI I did see that but I thought they were optionally breaking it out into its own component. My bad.
@Gray-tailed Tattler Perfect! Working now. Thx!
Turkish Van
Glad to help! Make sure to mark the solution, so the thread can get closed!