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

useActionState/useFormState state is undefined despite passing initial value after successful submission and redirect #68549

Closed
pawelblaszczyk5 opened this issue Aug 5, 2024 · 2 comments · Fixed by #69945
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@pawelblaszczyk5
Copy link

Link to the code that reproduces this issue

https://github.com/pawelblaszczyk5/use-action-state-missing-state

To Reproduce

  1. Start the app
  2. Try to enter something different than "John" in the input and submit it
  3. Observe correct error being displayed
  4. Enter correct answer "John" and submit the form
  5. Observe the client-side error because of the action state being undefined despite having an initial value

Current vs. Expected behavior

Current:

After successful submission and being redirected back to the page with the form the action state is undefined despite having an initial value provided. Types don't reflect that possibility as well.

Expected:

After successful submission and being redirected back to the page with the form the action state is back to the initial state

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.15.7
Relevant Packages:
  next: 15.0.0-canary.102 // Latest available version is detected (15.0.0-canary.102).
  eslint-config-next: N/A
  react: 19.0.0-rc-06d0b89e-20240801
  react-dom: 19.0.0-rc-06d0b89e-20240801
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

From what I've tested it seems to be present even back in the 14.0.0 release that marked server actions as stable (with useFormState instead of useActionState of course).

@pawelblaszczyk5 pawelblaszczyk5 added the bug Issue was opened via the bug report template. label Aug 5, 2024
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Aug 5, 2024
@samcx
Copy link
Member

samcx commented Aug 21, 2024

@pawelblaszczyk5 Thank you for submitting an issue—taking a look!

Copy link
Contributor

github-actions bot commented Oct 4, 2024

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Oct 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants